From 2035951aa1ff535c1e97c90d4a19d581ea97dbe2 Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Sun, 7 Feb 2021 22:54:55 +0000 Subject: [PATCH] Remove handling for webhooks - they were not working and could lead to broken recurring contributions --- CRM/Core/Payment/StripeIPN.php | 20 +------------------- CRM/Stripe/Api.php | 6 ------ docs/releasenotes.md | 2 +- info.xml | 2 +- stripe.php | 2 +- 5 files changed, 4 insertions(+), 28 deletions(-) diff --git a/CRM/Core/Payment/StripeIPN.php b/CRM/Core/Payment/StripeIPN.php index 70e52b15..51cae354 100644 --- a/CRM/Core/Payment/StripeIPN.php +++ b/CRM/Core/Payment/StripeIPN.php @@ -362,24 +362,7 @@ class CRM_Core_Payment_StripeIPN { return TRUE; case 'customer.subscription.updated': - if (!$this->getSubscriptionDetails()) { - // Not matched with an existing subscription in CiviCRM - return TRUE; - } - if (empty($this->previous_plan_id)) { - // Not a plan change...don't care. - return TRUE; - } - - // The Stripe "plan" has been changed. Update the following information within CiviCRM: - // Amount, frequency_unit, frequency_interval - civicrm_api3('ContributionRecur', 'create', [ - 'id' => $this->contribution_recur_id, - 'amount' => $this->plan_amount, - 'auto_renew' => 1, - 'frequency_unit' => $this->frequency_unit, - 'frequency_interval' => $this->frequency_interval, - ]); + // Subscription is updated. This used to be "implemented" but didn't work return TRUE; case 'customer.subscription.deleted': @@ -483,7 +466,6 @@ 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); diff --git a/CRM/Stripe/Api.php b/CRM/Stripe/Api.php index 5e79f5a8..08204c54 100644 --- a/CRM/Stripe/Api.php +++ b/CRM/Stripe/Api.php @@ -182,12 +182,6 @@ class CRM_Stripe_Api { case 'id': return (string) $stripeObject->id; - - case 'previous_plan_id': - if (preg_match('/\.updated$/', $stripeObject->type)) { - return (string) $stripeObject->data->previous_attributes->plan->id; - } - break; } return NULL; } diff --git a/docs/releasenotes.md b/docs/releasenotes.md index d7c01906..e2306835 100644 --- a/docs/releasenotes.md +++ b/docs/releasenotes.md @@ -11,7 +11,7 @@ Releases use the following numbering system: ## Release 6.5.7 (not yet released 2021-01-23) -* Don't change 'created_date' when subscription is updated. +* Remove handling for `customer.subscription.updated` webhooks - they were not working and could lead to broken recurring contributions. * Rename ProcessStripe job to "Stripe: Cleanup". ## Release 6.5.6 diff --git a/info.xml b/info.xml index 0ec76125..6c112115 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>2021-01-23</releaseDate> + <releaseDate>2021-02-07</releaseDate> <version>6.5.7-dev</version> <develStage>beta</develStage> <compatibility> diff --git a/stripe.php b/stripe.php index 79059ed4..f1d32269 100644 --- a/stripe.php +++ b/stripe.php @@ -10,7 +10,7 @@ */ require_once 'stripe.civix.php'; -require_once __DIR__.'/vendor/autoload.php'; +require_once __DIR__ . '/vendor/autoload.php'; use CRM_Stripe_ExtensionUtil as E; -- GitLab