From 752072ee63aaf646d4b2b56861648db9b139821e Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Tue, 20 Oct 2020 17:29:28 +0100 Subject: [PATCH] Fix #270 500 Internal Server error for the customer.subscription.updated event --- CRM/Core/Payment/StripeIPN.php | 16 ++++++---------- CRM/Stripe/Api.php | 6 ------ docs/releasenotes.md | 2 +- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/CRM/Core/Payment/StripeIPN.php b/CRM/Core/Payment/StripeIPN.php index 41fecef8..2e09f2e3 100644 --- a/CRM/Core/Payment/StripeIPN.php +++ b/CRM/Core/Payment/StripeIPN.php @@ -46,11 +46,9 @@ class CRM_Core_Payment_StripeIPN { protected $customer_id = NULL; protected $charge_id = NULL; protected $previous_plan_id = NULL; - protected $plan_id = NULL; protected $plan_amount = NULL; protected $frequency_interval = NULL; protected $frequency_unit = NULL; - protected $plan_name = NULL; protected $plan_start = NULL; /** @@ -356,7 +354,7 @@ class CRM_Core_Payment_StripeIPN { return TRUE; case 'customer.subscription.updated': - if (!$this->setInfo()) { + if (!$this->getSubscriptionDetails()) { return TRUE; } if (empty($this->previous_plan_id)) { @@ -430,16 +428,9 @@ class CRM_Core_Payment_StripeIPN { return FALSE; } - $this->previous_plan_id = CRM_Stripe_Api::getParam('previous_plan_id', $this->_inputParameters); $this->invoice_id = $this->retrieve('invoice_id', 'String', FALSE); $this->receive_date = $this->retrieve('receive_date', 'String', FALSE); $this->charge_id = $this->retrieve('charge_id', 'String', FALSE); - $this->plan_id = $this->retrieve('plan_id', 'String', FALSE); - $this->plan_amount = $this->retrieve('plan_amount', 'String', FALSE); - $this->frequency_interval = $this->retrieve('frequency_interval', 'String', FALSE); - $this->frequency_unit = $this->retrieve('frequency_unit', 'String', FALSE); - $this->plan_name = $this->retrieve('plan_name', 'String', FALSE); - $this->plan_start = $this->retrieve('plan_start', 'String', FALSE); $this->amount = $this->retrieve('amount', 'String', FALSE); if (($this->_inputParameters->data->object->object !== 'charge') && ($this->charge_id !== NULL)) { @@ -481,6 +472,11 @@ class CRM_Core_Payment_StripeIPN { return FALSE; } } + $this->previous_plan_id = CRM_Stripe_Api::getParam('previous_plan_id', $this->_inputParameters); + $this->plan_amount = $this->retrieve('plan_amount', 'String', FALSE); + $this->frequency_interval = $this->retrieve('frequency_interval', 'String', FALSE); + $this->frequency_unit = $this->retrieve('frequency_unit', 'String', FALSE); + $this->plan_start = $this->retrieve('plan_start', 'String', FALSE); return TRUE; } diff --git a/CRM/Stripe/Api.php b/CRM/Stripe/Api.php index ccd6429c..fb215534 100644 --- a/CRM/Stripe/Api.php +++ b/CRM/Stripe/Api.php @@ -115,12 +115,6 @@ class CRM_Stripe_Api { case 'currency': return (string) mb_strtoupper($stripeObject->plan->currency); - case 'plan_id': - return (string) $stripeObject->plan->id; - - case 'plan_name': - return (string) $stripeObject->plan->name; - case 'plan_start': return self::formatDate($stripeObject->start_date); diff --git a/docs/releasenotes.md b/docs/releasenotes.md index 7b745b16..af7d06f0 100644 --- a/docs/releasenotes.md +++ b/docs/releasenotes.md @@ -13,7 +13,7 @@ Releases use the following numbering system: * Fix [#258](https://lab.civicrm.org/extensions/stripe/-/issues/258) Credit card element doesn't load in "Submit credit card contribution" popup form on backend. * Fix [#262](https://lab.civicrm.org/extensions/stripe/-/issues/262) Fix `customer.subscription.deleted` webhook event not working (500 internal server error). - +* Fix [#270](https://lab.civicrm.org/extensions/stripe/-/issues/270) Fix 500 Internal Server error for the customer.subscription.updated event ## Release 6.5.2 * [!129](https://lab.civicrm.org/extensions/stripe/-/merge_requests/129) Don't check inactive membership blocks for separate payment setting. -- GitLab