Automattic\WooCommerce\Gateways\PayPal
WebhookHandler::process_webhook
Process the webhook event.
Method of the class: WebhookHandler{}
No Hooks.
Returns
null. Nothing (null).
Usage
$WebhookHandler = new WebhookHandler(); $WebhookHandler->process_webhook( $request ): void;
- $request(WP_REST_Request) (required)
- The request object.
Changelog
| Since 10.5.0 | Introduced. |
WebhookHandler::process_webhook() WebhookHandler::process webhook code WC 10.7.0
public function process_webhook( \WP_REST_Request $request ): void {
$data = $request->get_json_params();
if ( ! is_array( $data ) || empty( $data['event_type'] ) || empty( $data['resource'] ) ) {
\WC_Gateway_Paypal::log( 'Invalid PayPal webhook payload: ' . wc_print_r( $data, true ) );
return;
}
\WC_Gateway_Paypal::log( 'Webhook received: ' . wc_print_r( PayPalHelper::redact_data( $data ), true ) );
switch ( $data['event_type'] ) {
case 'CHECKOUT.ORDER.APPROVED':
$this->process_checkout_order_approved( $data );
break;
case 'PAYMENT.CAPTURE.PENDING':
$this->process_payment_capture_pending( $data );
break;
case 'PAYMENT.CAPTURE.COMPLETED':
$this->process_payment_capture_completed( $data );
break;
case 'PAYMENT.AUTHORIZATION.CREATED':
$this->process_payment_authorization_created( $data );
break;
default:
\WC_Gateway_Paypal::log( 'Unhandled PayPal webhook event: ' . wc_print_r( PayPalHelper::redact_data( $data ), true ) );
break;
}
}