WC_REST_Paypal_Webhooks_Controller::process_webhookpublicWC 1.0

Process the webhook.

Method of the class: WC_REST_Paypal_Webhooks_Controller{}

No Hooks.

Returns

WP_REST_Response. The response object.

Usage

$WC_REST_Paypal_Webhooks_Controller = new WC_REST_Paypal_Webhooks_Controller();
$WC_REST_Paypal_Webhooks_Controller->process_webhook( $request );
$request(WP_REST_Request) (required)
The request object.

WC_REST_Paypal_Webhooks_Controller::process_webhook() code WC 10.8.1

public function process_webhook( WP_REST_Request $request ) {
	$webhook_handler = new PayPalWebhookHandler();

	try {
		$webhook_handler->process_webhook( $request );
		return new WP_REST_Response( array( 'message' => 'Webhook processed successfully' ), 200 );
	} catch ( \Throwable $e ) {
		WC_Gateway_Paypal::log( 'Error processing webhook: ' . $e->getMessage() );
		return new WP_REST_Response( array( 'error' => __( 'Webhook processing failed.', 'woocommerce' ) ), 500 );
	}
}