Skip to content

Commit

Permalink
Merge pull request woocommerce#2079 from woocommerce/PCP-2727-do-not-…
Browse files Browse the repository at this point in the history
…handle-vault-payment-token-created-webhook-for-vault-v-3

Do not handle VAULT.PAYMENT-TOKEN.CREATED webhook for Vault v3 (2727)
  • Loading branch information
Dinamiko authored Mar 6, 2024
2 parents da6d57b + 0a892a5 commit a6df228
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ public function responsible_for_request( WP_REST_Request $request ): bool {
* @return WP_REST_Response
*/
public function handle_request( WP_REST_Request $request ): WP_REST_Response {
$resource_version = $request['resource_version'] ?? '';
if ( $resource_version && $resource_version !== '2.0' ) {
return $this->success_response();
}

$customer_id = null !== $request['resource'] && isset( $request['resource']['customer_id'] )
? $request['resource']['customer_id']
: '';
Expand Down
7 changes: 6 additions & 1 deletion modules/ppcp-webhooks/src/IncomingWebhookEndpoint.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,9 +248,14 @@ public function handle_request( \WP_REST_Request $request ): \WP_REST_Response {
}
}

$event_type = $request['event_type'] ?: '';
if ( in_array( $event_type, array( 'BILLING_AGREEMENTS.AGREEMENT.CREATED' ), true ) ) {
return $this->success_response();
}

$message = sprintf(
'Could not find handler for request type %s',
$request['event_type'] ?: ''
$event_type
);
return $this->failure_response( $message );
}
Expand Down

0 comments on commit a6df228

Please sign in to comment.