Here is my unsubscribe function
public function cancelSubscription($ssid)
{
try {
\Stripe\Stripe::setApiKey(SSK);
$subscription = \Stripe\Subscription::retrieve($ssid);
if ($subscription['status'] == 'canceled') {
return $subscription['status'];
}
$subscription->cancel();
return $subscription;
} catch (Exception $e) {
echo '<pre>';
print_r($e->getMessage());
echo '</pre>';
die('error!- customer');
}
}
Its working fine but when I am trying to upgrade my plan or trying to subscribe again I am getting an error.
No such subscription:sub_EMYom4xxxxx
seems subscription id doesn't match after unsubscribe. Please suggest any solution. Thanks in advance.
You can't reactivate a subscription after explicitly canceling it. If you mark it for cancelation you have a window to "un-cancel" before the cancelation date hits.
In this case you are canceling immediately so you'd need to create a new subscription entirely. See https://stripe.com/docs/billing/subscriptions/canceling-pausing#pausing-a-subscription
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.