Skip to content
Snippets Groups Projects
Commit 00f8eaae authored by capo's avatar capo Committed by mattwire
Browse files

Fix cancelling subscriptions from the backend in CiviCRM < 5.25

parent 5255bd8e
No related branches found
No related tags found
1 merge request!1246.5
...@@ -1083,13 +1083,24 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment { ...@@ -1083,13 +1083,24 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
*/ */
public function cancelSubscription(&$message = '', $params = []) { public function cancelSubscription(&$message = '', $params = []) {
$propertyBag = \Civi\Payment\PropertyBag::cast($params); $propertyBag = \Civi\Payment\PropertyBag::cast($params);
// Fix Unknown property 'subscriptionId' (for < 5.25)
// @see https://lab.civicrm.org/extensions/stripe/-/issues/234
if (version_compare(CRM_Utils_System::version(), '5.25', '<')) {
if (isset($params['subscriptionId'])) {
$propertyBag->setRecurProcessorID($params['subscriptionId']);
}
}
if (!$propertyBag->has('recurProcessorID')) { if (!$propertyBag->has('recurProcessorID')) {
throw new \Civi\Payment\Exception\PaymentProcessorException("cancelSubscription requires the recurProcessorID"); throw new \Civi\Payment\Exception\PaymentProcessorException("cancelSubscription requires the recurProcessorID");
} }
// contributionRecurID is set when doCancelRecurring is called directly (from 5.25) // contributionRecurID is set when doCancelRecurring is called directly (from 5.25)
if (!$propertyBag->has('contributionRecurID')) { if (!$propertyBag->has('contributionRecurID')) {
$contrib_recur = civicrm_api3('ContributionRecur', 'getsingle', ['processor_id' => $propertyBag->getRecurProcessorID()]); $contrib_recur = civicrm_api3('ContributionRecur', 'getsingle', [
'trxn_id' => $propertyBag->getRecurProcessorID(),
]);
$propertyBag->setContributionRecurID($contrib_recur['id']); $propertyBag->setContributionRecurID($contrib_recur['id']);
} }
......
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