简体   繁体   中英

Uncancel stripe subscription when using subscriptionItems (or remove and add again the subscriptionItem) with handling of subscrition date origin

I'm working for an online course provider where students can subscribe to mutiple teachers.

Technically, in app subscriptions are represented by a subscription per customer plus a subscriptionItem per teacher subscribed. I use subscriptionItems as this is the recommanded way to handle multiple subscriptions.

The problem

In my scenario, the student subscribes to teacherA. Some months after, the student unsubscribes from teacherA. He still have access to teacherA's premium content until the end of the subscription period because he paid for it (billing happens at the beginning of the subscription period). Some weeks later he changes his mind and resubscribe...

What happen if he REsubscribe before the end of the subscription month he already have paid for ?

My wish is that when I add the subscriptionItem with the same price, it acts like he has never unsubscribed. But is not that clear when I read the docs.

Have you got a clue on how to handle such a scenario ?

My researches

I found how to delete subscriptionItems, but I didn't find any reference on how to reenable/add back those subscriptionItems and REbilling the customer with respect to the monthly date of subscription and without extra billing.

Depending on how you manage your Products, you may wish to consider an entirely new Subscription. If the Customer is re-susbuscribing to the same general "Premium" service, keeping the same would make sense. If they are now subscribing to some "Premium B" (where before they subscribed to "Premium A") then may a new subscription would be better.

To answer you question though, you can r e-activate subscriptions set to cancel at period end (but which are still active), you can just update the subscription and set cancel_at_period_end=false and the subscription will continue as normal. You can update items to change the Plan/Price if needed, or leave the existing ones in place.

If the subscription is no longer active, you will need to create a new subscription.

Update : To replace the price on the existing subscription item while undoing a cancellation you'd send a request like this:

curl https://api.stripe.com/v1/subscriptions/sub_123 \
  -u sk_test_123: \
  -d cancel_at_period_end=false \
  -d 'items[0][id]=si_456' \
  -d 'items[0][price]=price_789'

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM