#Osiris
1 messages · Page 1 of 1 (latest)
Have you tried immediately making the calls to finalize and attempt payment on the invoice? I think that would make the subscription go to what you have this set to in your settings
I thought of this but can't think of a reliable trigger. What do you suggest ?
The invoice.created event should be sent every time this happens
Or customer.subscription.updated which may be better if you are asking specifically about doing this when they leave a trialing state. You can check the invoice's previous status (if it has changed) in the previous_attributes property on the event
yeah but its still not reliable as the invoice may have been paid.
will have to fetch latest_invoice's payment status
its create_invoice on missing payment method. if payment method is there, it would charge it automatically
I may not be picturing this right. So you have a trialing subscription, it's trial ends and it goes to some price that requires payment
And then you are calling create invoice to double check the default payment method is chargable?
Or is create invoice for something else?
I am creating checkout link from following settings:
subscription_data: {
trial_settings: {
end_behavior: { missing_payment_method: 'create_invoice' }
},
trial_period_days:7
},
sorry edited.
so when trial ends after 7 days, if payment-method is missing it creates invoice otherwise just charges the pm
above aside, finalising invoice didn't charge the customer as there is no pm and it says retry in 1 hour ?
wait lets restart
Yes it will behave as you described if there is no PaymentMethod collected... an Invoice will be created and attempt to charge
I need a way to move subscription to non-terminal state (not cancelled) when payment-collection isn't possible. immediately not after being active for 1 hour
It shouldn't move to canceled until all of your retries are expired
What are your retry settings set for at https://dashboard.stripe.com/settings/billing/automatic
I am talking about trial to active transition not recurring
we have some restrictions in place for trialing status compared to active in our product. Now the main issue is just after trial ends, for 1 hour atleast subscriptions remain active ! And during this window people get free-reign
It shouldn't be active? It should move to past_due, no?
Can you share an example Subscription ID that I can look at?
sub_1Mr0ciLJhqt57ntnCLqSAKoq
at exactly 8:39IST this moved to active from trialing and a draft invoice was created. I tried to fail the invoice by manually finalizing it via api. Its finalized now but will be charged in 1 hour remained.
Looking
Looks like you finalized the invoice yourself instead of letting the Subscription cycle as normal?
Ah sorry
I see what you are saying
So what you want to do then is listen for customer.subscription.updated for when a Sub moves from trialing --> active
Then you can finalize/pay immediately via https://stripe.com/docs/api/invoices/pay
If you just finalize it will still wait an hour to charge
hmm ok. So
- check for trialing -> active
- check whether latest invoice was created within last few minutes and unpaid.
- pay immediately
Yep pretty much
cool thanks I was missing the pay part. Still lot of work for just marking a subscription overdue/past_due
Well it would be marked past_due automatically in 1 hour when the automatic payment fails
But if you don't want to provision for this one hour then you have to handle that yourself
trial_settings: { end_behavior: { missing_payment_method: 'cancel' }
},
This should support past_due maybe.(personal opinion) There is no point in creating invoice when payment-method is absent ?
anyways no point in discussing unsupported feature. Thanks for help !
wait, @raw jacinth pay doesn't work when method is absent ! The api failed.
Right that should happen and move the Sub to past_due, no?
oh right it moved. My bad. had to refresh, it was cached