diff --git a/CRM/Core/Payment/StripeIPN.php b/CRM/Core/Payment/StripeIPN.php index 1bb14384c9a03539c6f79749330847002ec24474..528fd1e57a50b4c058a42338b001ae7d6c505c92 100644 --- a/CRM/Core/Payment/StripeIPN.php +++ b/CRM/Core/Payment/StripeIPN.php @@ -265,7 +265,7 @@ class CRM_Core_Payment_StripeIPN { case 'customer.subscription.deleted': // Subscription is cancelled - if (!$this->setInfo()) { + if (!$this->getSubscriptionDetails()) { // Subscription was not found in CiviCRM return TRUE; } @@ -431,7 +431,6 @@ class CRM_Core_Payment_StripeIPN { } $this->previous_plan_id = CRM_Stripe_Api::getParam('previous_plan_id', $this->_inputParameters); - $this->subscription_id = $this->retrieve('subscription_id', 'String', FALSE); $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); @@ -452,6 +451,21 @@ class CRM_Core_Payment_StripeIPN { } $this->setBalanceTransactionDetails($balanceTransactionID); + // Get the CiviCRM recurring contribution that matches the Stripe subscription (if we have one). + $this->getSubscriptionDetails(); + // Get the CiviCRM contribution that matches the Stripe metadata we have from the event + return $this->getContribution(); + } + + /** + * Get the recurring contribution from the Stripe event parameters (subscription_id) + * and set subscription_id, contribution_recur_id vars. + * + * @return bool + * @throws \CRM_Core_Exception + */ + public function getSubscriptionDetails() { + $this->subscription_id = $this->retrieve('subscription_id', 'String', FALSE); // Additional processing of values is only relevant if there is a subscription id. if ($this->subscription_id) { // Get the recurring contribution record associated with the Stripe subscription. @@ -467,9 +481,7 @@ class CRM_Core_Payment_StripeIPN { return FALSE; } } - - // Get the CiviCRM contribution that matches the Stripe metadata we have from the event - return $this->getContribution(); + return TRUE; } /** diff --git a/docs/releasenotes.md b/docs/releasenotes.md index 6951c48206aceddaade0f142a947c2b1336497fa..7b745b1690a25d95c68a309673df6bbe04dc9bc4 100644 --- a/docs/releasenotes.md +++ b/docs/releasenotes.md @@ -9,9 +9,10 @@ Releases use the following numbering system: * **[BC]**: Items marked with [BC] indicate a breaking change that will require updates to your code if you are using that code in your extension. -## Release 6.5.3 (not yet released 2020-10-16) +## Release 6.5.3 (not yet released 2020-10-20) * 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). ## Release 6.5.2 diff --git a/info.xml b/info.xml index bc9063f454c5f84e388d0d62c04fb2d2b10c6250..1f3c96bc318d7b84799b72a4dc769f586bdc5677 100644 --- a/info.xml +++ b/info.xml @@ -15,7 +15,7 @@ <author>Matthew Wire (MJW Consulting)</author> <email>mjw@mjwconsult.co.uk</email> </maintainer> - <releaseDate>2020-10-16</releaseDate> + <releaseDate>2020-10-20</releaseDate> <version>6.5.3-dev</version> <develStage>beta</develStage> <compatibility>