#MYoussef-subscription
1 messages · Page 1 of 1 (latest)
i have a special case where the customer can create many subscription with same plan id, i contacted stripe support and they told me that i should create a checkout session with setup mode then passing the payment method id to create subscriptions in backend (but i found that this may be make a problem for example what if the customer credit is enough only for 2 subscription although he bought 3 subscriptions, at this time i should refund him the money of 2 subscriptions because he should pay for the 3 subscriptions or not)
i think in another solution to create a checkout session in payment mode to collect the whole amount of subscriptions then create subscriptions in backend with first year (paid) and passing the payment method id to use it for auto-renewal
is it valid ? kindly advise
Why can you not just a create a single Checkout Session with multiple line items for the same Price?
if i make that it gave me an error that you can not create two subscriptions with the same plan/price id
Well it would be a single subscription, so I guess that's the issue
What you want to do will work, sure
how to achieve that ?
- Create a Checkout Session for the required amount of 3x subscription totals for the 1st year.
- You will want to pass
payment_intent_data.setup_future_usage: 'off_session'so that the payment details are correctly saved for future recurring payments. - On success (via
checkout.session.completed) create the Subscriptions accordingly. I guess you'd initiate a year trial to 'skip' the first billing cycle (or use a schedule). - Use the saved Payment Method from the Checkout Session (it'll be on the Customer object) and set as default PM for the Subscriptions.
if i created a subscription and set session.DefaultPaymentMethod = payment method if (from checkout session) and make the first year is trial (is this mean the customer will not be charged at first year and in the second year he will be charged from payment method that i passed ? )
Yes, exactly
and if the customer uncheck auto renewal then i will create a subscription with trial_period_days= 365 and set cancel_at_period_end = true
?
Why would you want to cancel at period end?
Are you subscribing to yearly interval prices?
because some times the customer can buy a subscription for only one year and he did not want auto renewal
yes, the subscriptions that i provide is yearly
Then you would manage that accordingly, yes. But if you set cancel_at_period_end then it will cancel after the trial period
But generally you'd provide a UI for your customer to cancel if they wish (or use the customer portal)
i provide a UI
-
Create checkout session with payment mode for the required 3x subscriptions
-
set payment_intent_data.setup_future_usage: 'off_session'
-
on success ( create 3x subscriptions and set DefaultPaymentMethod = pyament method Id from checkout session and set trial_period_days = 365 (because the customer paid for 1st year from checkout session).
-
if the customer uncheck auto renewal then i will set cancel_at_period_end = true (which is mean that the subscription will be cancelled automatically after the 1st tiral period)
is that valid ?
Yup, sounds good to me!
Although the payment method from Checkout isn't directly available on the Checkout Session object
even if i used expand object ?
I guess you could expand payment_intent, yes
i want to make sure that if i created a subscription with trial_days =365 and cancel_at_end = true then the customer will not be charged (because i charged the customer from checkout session)
There would be no subsequent renewal payments after the trial period, no
do you have any advise that i should consider in my case ?
I think we've covered everything! Do you have a specific concern?
no, thanks
Perfect!