Skip to content
Snippets Groups Projects
Commit 652c1fcf authored by mattwire's avatar mattwire Committed by mattwire
Browse files

Fix #262 webhook event not working (500 internal server error).

parent bab93861
No related branches found
No related tags found
1 merge request!132Issue262
...@@ -265,7 +265,7 @@ class CRM_Core_Payment_StripeIPN { ...@@ -265,7 +265,7 @@ class CRM_Core_Payment_StripeIPN {
case 'customer.subscription.deleted': case 'customer.subscription.deleted':
// Subscription is cancelled // Subscription is cancelled
if (!$this->setInfo()) { if (!$this->getSubscriptionDetails()) {
// Subscription was not found in CiviCRM // Subscription was not found in CiviCRM
return TRUE; return TRUE;
} }
...@@ -431,7 +431,6 @@ class CRM_Core_Payment_StripeIPN { ...@@ -431,7 +431,6 @@ class CRM_Core_Payment_StripeIPN {
} }
$this->previous_plan_id = CRM_Stripe_Api::getParam('previous_plan_id', $this->_inputParameters); $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->invoice_id = $this->retrieve('invoice_id', 'String', FALSE);
$this->receive_date = $this->retrieve('receive_date', 'String', FALSE); $this->receive_date = $this->retrieve('receive_date', 'String', FALSE);
$this->charge_id = $this->retrieve('charge_id', 'String', FALSE); $this->charge_id = $this->retrieve('charge_id', 'String', FALSE);
...@@ -452,6 +451,21 @@ class CRM_Core_Payment_StripeIPN { ...@@ -452,6 +451,21 @@ class CRM_Core_Payment_StripeIPN {
} }
$this->setBalanceTransactionDetails($balanceTransactionID); $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. // Additional processing of values is only relevant if there is a subscription id.
if ($this->subscription_id) { if ($this->subscription_id) {
// Get the recurring contribution record associated with the Stripe subscription. // Get the recurring contribution record associated with the Stripe subscription.
...@@ -467,9 +481,7 @@ class CRM_Core_Payment_StripeIPN { ...@@ -467,9 +481,7 @@ class CRM_Core_Payment_StripeIPN {
return FALSE; return FALSE;
} }
} }
return TRUE;
// Get the CiviCRM contribution that matches the Stripe metadata we have from the event
return $this->getContribution();
} }
/** /**
......
...@@ -9,9 +9,10 @@ Releases use the following numbering system: ...@@ -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. * **[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 [#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 ## Release 6.5.2
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<author>Matthew Wire (MJW Consulting)</author> <author>Matthew Wire (MJW Consulting)</author>
<email>mjw@mjwconsult.co.uk</email> <email>mjw@mjwconsult.co.uk</email>
</maintainer> </maintainer>
<releaseDate>2020-10-16</releaseDate> <releaseDate>2020-10-20</releaseDate>
<version>6.5.3-dev</version> <version>6.5.3-dev</version>
<develStage>beta</develStage> <develStage>beta</develStage>
<compatibility> <compatibility>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment