#deputycheese

1 messages ยท Page 1 of 1 (latest)

uncut juncoBOT
ivory sequoia
#

๐Ÿ‘‹ happy to help

#

it really depends how your flow works

low flame
#

Let me explain

ivory sequoia
#

sure

low flame
#

So basically the user books a monthly subscription on our website. He can change the subscription status every time he wants during that month (= renew or end at the current cycle).

#

But if an off session payment then fails after a month we want to automatically cancel his subscription on our side. That's why I am listening to those events.

#

He then always has the possibility to book a new subscription on our website, but we dont want to deal with the renewal if a payment fails.

#

You still there?

ivory sequoia
#

please be patient, I will be with you shortly

#

it's a bit busy on discord

low flame
#

no problem

#

Another question would be: if a renewal payment (off session) cannot be made because the credit card is stolen or because the user has to confirm it via 3d secure (we also want it to be cancelled in that case), is it enough to listen to invoice.finalization_failed, invoice.payment_failed and invoice.payment_action_required to cancel the subscription?

ivory sequoia
#

I'm with you now

#

will read through your messages and reply asap

#

then you only need to listen to customer.subscription.deleted to stop the subscription from your side

low flame
ivory sequoia
#

basically instead of canceling the subscription yourself

low flame
#

Ah you mean to remove the payment retries?

ivory sequoia
#

you can let Stripe automatically cancel the subscription after the payment fails

ivory sequoia
low flame
#

But I dont want the user to go to stripe

ivory sequoia
#

they won't

low flame
#

Thats why I wanted to cancel the subscription as soon as the payment fails

ivory sequoia
#

you decide what the flow is

low flame
ivory sequoia
#

are you in India?

low flame
low flame
low flame
# low flame

Is it correct that in this case if the payment fails I get the customer.subscription.deleted event and I can ignore everything else?

#

(I removed the retries)

ivory sequoia
#

ok why do they need to do 3DS for each invoice then?

low flame
#

He said 3ds can occur also for those automatic renewals

ivory sequoia
#

yes it can occur

#

randomly

low flame
#

And then we would like the customer to just book a new subscription where he pays again on our website

ivory sequoia
#

ok

low flame
#

(and confirms 3ds during checkout if it happens there, on session)

ivory sequoia
#

but you know that you can do another workflow in that case

low flame
#

which one?

ivory sequoia
#

where you just take the PI of the invoice and send the customer an email with a link to your website where they only need to authenticate 3DS

low flame
#

Yes but we dont want that at the moment (because we dont know if and when he will confirm/pay). we would rather have the subscription cancelled until he really pays

ivory sequoia
#

up to you

low flame
#

Okay thanks but that helped already

#

Is there a way to differentiate between a subscription that has normally ended (because the user paused it) and a subscription that has ended due to a payment error? I think in both cases the event customer.subscription.deleted gets called?

ivory sequoia
low flame
#

Aaaaah perfect

#

Thank you so much, you've been a great help (again and again :-))

ivory sequoia
#

let me know if you need any more help

low flame
#

Thats it for now, thanks!

#

Last question: the subscription.deleted event will also be called when a subscription is paused?

#

for example: the user has booked 1 months, paused it and then after 30 days I get the event too so I can disable his subscription?

ivory sequoia
low flame
#

Okay that will be called after 30 days, not when he pauses it, right?

ivory sequoia
#

no

#

it will be called when you "pause" the subscription for the customer

low flame
#

He can pause it anytime (= change the status if the subscription should be renewed after a month). but what event would I listen to to disable his subscription on our side after the 30 days (if its paused then)?

ivory sequoia
#

you don't have another event that happens 30 days after a susbcription is paused

#

you need to create a cron job that looks at the paused subscriptions for more than 30 days

low flame
#

No at the day the subscription ends I mean

ivory sequoia
#

and cancel them

low flame
#

Example: user books 1 month. after 5 days he changes the status to pause (so not to be renewed after a month). he then uses his subscription for 25 more days. and then after 30 days his subscription ends -> here I wont get a notification about it?

uncut juncoBOT
ivory sequoia
#

that's not really how pausing works with Stripe

low flame
#

I thought that if he pauses the subscription he wont be charged after the current cycle ends?

#

Ah sorry

#

My fault

#

We dont pause

#

We just use cancel_at_period_end

#

And use subscriptions->update with that

#

Sorry for the confusion

thorn sage
#

customer.subscription.deleted would fire at the end of the period

low flame
#

Okay perfect

#

Thats exactly what we needed

#

One last last question

thorn sage
#

Sure!

low flame
#

If the customer paid at 12am on January 1st (monthly). Will we get notified before 12am on February 1st if the payment fails/subscription ended?

thorn sage
#

We'd attempt payment ~1 hour after the billing_period_end timestamp

low flame
#

How do we handle the 1 hour gap in that case?

#

Because officially he hasnt paid and it ended

thorn sage
#

Which gap?

low flame
#

And 1hour later the payment attempt is tried and we only then get the notification

#

~1 hour after the billing_period_end

thorn sage
#

Is this in a scenario where cancel_at_period_end: true?

low flame
#

No in the other case

#

cancel_at_period_end: false

thorn sage
#

You can't really. Only thing you can try is to manually finalize yourself on receipt on invoice.created. That will ~immediately attempt payment

low flame
#

Mmmh okay