From 2857e179409ae1fe51ed19bae045f85f8c52525b Mon Sep 17 00:00:00 2001 From: vuckro Date: Wed, 10 Jun 2026 12:36:30 +0200 Subject: [PATCH] fix(paypal): load membership and customer with the correct helpers in Express IPN MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit In PayPal_Gateway::process_webhooks() the IPN `custom` field is "payment_id|membership_id|customer_id", but all three ids were loaded with wu_get_payment(), so $membership and $customer were either the wrong object type or false — leading to wrong-object data corruption (and a fatal when the later code calls Membership-only methods like is_active()/renew()). Also guard the index count so a malformed `custom` value doesn't raise undefined-index warnings. Use wu_get_membership() and wu_get_customer() for the respective ids. Co-Authored-By: Claude Fable 5 --- inc/gateways/class-paypal-gateway.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/inc/gateways/class-paypal-gateway.php b/inc/gateways/class-paypal-gateway.php index 8d2b92e9b..949a0097e 100644 --- a/inc/gateways/class-paypal-gateway.php +++ b/inc/gateways/class-paypal-gateway.php @@ -954,10 +954,11 @@ public function process_webhooks(): bool { $custom = ! empty($posted['custom']) ? explode('|', (string) $posted['custom']) : []; - if (is_array($custom) && ! empty($custom)) { + // `custom` is built as "payment_id|membership_id|customer_id" (see set_express_checkout()). + if (is_array($custom) && count($custom) >= 3) { $payment = wu_get_payment(absint($custom[0])); - $membership = wu_get_payment(absint($custom[1])); - $customer = wu_get_payment(absint($custom[2])); + $membership = wu_get_membership(absint($custom[1])); + $customer = wu_get_customer(absint($custom[2])); } if ( ! empty($posted['recurring_payment_id'])) {