Commit 63f5cd4f7a8 for woocommerce

commit 63f5cd4f7a84f13e69f128f49d0efccda92d5161
Author: Mayisha <33387139+Mayisha@users.noreply.github.com>
Date:   Fri Mar 27 00:33:03 2026 +0600

    PayPal Standard: Fix webhook handling for invalid links (#63834)

    * catch throwable

    * type safety for links array

    * remove exception

    * Add changefile(s) from automation for the following project(s): woocommerce

    * fix lint

    * return generic message

diff --git a/plugins/woocommerce/changelog/63834-fix-paypal-standard-prevent-fatal-for-strict-type b/plugins/woocommerce/changelog/63834-fix-paypal-standard-prevent-fatal-for-strict-type
new file mode 100644
index 00000000000..2700f28237b
--- /dev/null
+++ b/plugins/woocommerce/changelog/63834-fix-paypal-standard-prevent-fatal-for-strict-type
@@ -0,0 +1,4 @@
+Significance: patch
+Type: fix
+
+Fix PayPal Standard webhook handling for invalid links.
\ No newline at end of file
diff --git a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php
index 13fda534517..7c0f4083fec 100644
--- a/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php
+++ b/plugins/woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-paypal-webhooks-controller.php
@@ -88,8 +88,9 @@ class WC_REST_Paypal_Webhooks_Controller extends WC_REST_Controller {
 		try {
 			$webhook_handler->process_webhook( $request );
 			return new WP_REST_Response( array( 'message' => 'Webhook processed successfully' ), 200 );
-		} catch ( Exception $e ) {
-			return new WP_REST_Response( array( 'error' => $e->getMessage() ), 500 );
+		} catch ( \Throwable $e ) {
+			WC_Gateway_Paypal::log( 'Error processing webhook: ' . $e->getMessage() );
+			return new WP_REST_Response( array( 'error' => __( 'Webhook processing failed.', 'woocommerce' ) ), 500 );
 		}
 	}
 }
diff --git a/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php b/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php
index f04e02ecf95..cbcf764697e 100644
--- a/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php
+++ b/plugins/woocommerce/src/Gateways/PayPal/WebhookHandler.php
@@ -104,8 +104,13 @@ class WebhookHandler {

 			// Authorize or capture the payment after approval.
 			$paypal_intent = $event['resource']['intent'] ?? null;
-			$links         = $event['resource']['links'] ?? null;
 			$action        = PayPalConstants::INTENT_CAPTURE === $paypal_intent ? PayPalConstants::PAYMENT_ACTION_CAPTURE : PayPalConstants::PAYMENT_ACTION_AUTHORIZE;
+
+			$links = $event['resource']['links'] ?? array();
+			if ( ! is_array( $links ) ) {
+				$links = array();
+			}
+
 			$this->authorize_or_capture_payment( $order, $links, $action );
 		} else {
 			// This is unexpected for a CHECKOUT.ORDER.APPROVED event.