Skip to content
Snippets Groups Projects
Commit 094d3e0f authored by BorislavZlatanov's avatar BorislavZlatanov
Browse files

Fix cancelling of an existing subscription

parent dabc9e2d
No related branches found
No related tags found
No related merge requests found
......@@ -574,7 +574,11 @@ class CRM_Core_Payment_Stripe extends CRM_Core_Payment {
// card to be charged immediately. So, since Stripe only supports one
// subscription per customer, we have to cancel the existing active
// subscription first.
if (!empty($stripe_customer->subscription) && $stripe_customer->subscription->status == 'active') {
$subscriptions = $stripe_customer->offsetGet('subscriptions');
$data = $subscriptions->offsetGet('data');
$status = $data[0]->offsetGet('status');
if (!empty($subscriptions) && $status == 'active') {
$stripe_customer->cancelSubscription();
}
......
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