#Pain - trigger a subscription payment
1 messages · Page 1 of 1 (latest)
Yes that is one of the events that is generated .We actually have two ways for you to test this quickly:
One great thing that we released a bit ago are Test Clocks, with them, you can simulate any amount of time passing under different conditions to see what your subscriptions will do https://stripe.com/docs/billing/testing/test-clocks
In this specific scenario, you can also just create a subscription with a three second trial period and we will attempt to take payment soon after that
Oh that's awesome, will most likely use the test clock as I don't generate subscriptions using the API.
The dashboard only allows daily as the minimum
Nice! Glad we have something for you there
Appreciate the support, thank you.
From what I can see, it just sends the invoice.paid again with the same subscription ID, I am supposed to listen to this event correct?
or is there a different event I am supposed to be listening to for renewals on a subscription?
Yes, invoice.paid is a good event to listen to for information on subscription renewals. I think other events should be generated but that one will always happen on subscription renewal payments. Can you tell me a bit about what you are trying to do based on this event?
I am creating a software subscription, I have linked up the priceId to the plans, the customerId to the user and now I am creating the subscription with this data.
I create a subscription for the customer, now I am looking for the best way to handle the subscription renewal
I am currently storing this data in my database
My idea is to keep the boolean for active as long as it's active, when it's cancelled I will switch it to 0 (false)
Only storing the dates in my database to avoid calling the stripe api again as I list subscriptions
So yes, it would make sense to update that table when processing the invoice.paid event. I think on every renewal there should also be a customer.subscription.updated event that you can use to look at the Subscription's status without retrieving it in the API.
Those are the ones that I am listening to currently
The query execution is the invoice.paid event
I will take a look at this event too for that usage
my idea is to simply check the subscription id in the invoice.paid event and update my database subscriptions accordingly
what is the event that is invoked when the subscription isn't paid/failed to pay/card declined (or related)?
I can see that the charge.failed event is invoked
and also the customer.subscription.updated is invoked
Yes those events are created and you can see when the subscription moves to past_due
You can define how you want failed payments to be handled https://stripe.com/docs/billing/subscriptions/overview#recurring-charges
Depending on what you set up, you may want to listen for the customer.subscription.updated event where your subscription's status becomes unpaid or past_due
Oh I see,
I can also see that the payments will carry on being charged on a daily
(since it's a daily charge)
If I want to pause the subscription until it's manually renewed is there a way to do this?
Oh I found the dashboard settings, is there any other way?
as those settings aren't really suitable for what I'm attempting to do
Can you tell me a bit more about the flow that you want here?
Basically, I want a charge to happen based on the subscription time, if the payment fails I want to pause/cancel the subscription after one failed charge attempt and allow the customer to renew it manually (I wish to allow the subscription to be manually renewed for 7 days maximum).
from what I'm understanding so far is I can listen to customer.subscription.updated for the status past_due and set the subscription to inactive in my database as soon as it fails, but how do I stop the subscription from attempting to charge the customer again?
In your billing settings you can set your retry schedule to have no entries https://dashboard.stripe.com/settings/billing/automatic
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I think that should make the subscription go to past due as soon as the first payment happens
I see
If I set this status to 7 days
Will that achieve what I just stated?
The subscription will be past_due as soon as first payment fails
The subscription will be in that state for 7 days (this should allow me to offer the user a manual renewal chance) then it would get cancelled, correct?
👋 stepping in here for @bold whale as they need to step away. Catchin up
Do you want this behavior to happen on the first charge for the Subscription as well?
Or do you only want it on renewals?
Okay so just to be clear... if the first payment fails when you start a Subscription, that Subscription will expire in 23 hours.
No that is for renewals
After I changed it the subscription didn't get cancelled anymore
I attached the card that fails
Sure, see how the first payment was successful?
Yes,
So only if the first payment fails?
Correct.
If you haven't given a read through https://stripe.com/docs/billing/subscriptions/overview I would recommend it!
You can get around this by setting a trial on the Sub
Okay so that's fine, I only save it if the first payment succeeds
Then the first payment will always succeed
Okay that works
Just wanted to clarify
Got it, I want to do it after that payment
Sounds good
So if the renewal payment fails
I only wish to attempt 1 renewal and if that fails, it wont try again (I've achieved that now)
Now I wish to keep that subscription "alive" for 7 days
to allow the customer to attempt a manual renewal
Gotcha, then yeah you want to just adjust your settings to either "mark the subscription as unpaid" or "leave the subscription as is" if all retries fail
And not cancel
This is the right setting?
I wish to cancel the subscription after 7 days
If it isn't paid
No that is for 3DS confirmation
You want to adjust the settings under "Manage failed payments"
Yep you want to change those settings
That would cause it to cancel the subscription as soon as it fails the first time
Correct
I don't wish to cancel it straight away
So you would change that
To "mark as unpaid" or "leave as is"
Then you are going to have to cancel the Sub yourself at 7 days
Via the API
Oh I see
Alternatively, you could just retry again at 7 days and if that fails then cancel.
Then you can use the settings to cancel
I believe that might cause some issues if it does go through
I will use the API route
So just to confirm this flow, I set the retry schedule to none
=> If payment fails the renew it will not renew it anymore
=> After 7 days I must send an api request to cancel the subscription myself
Yep that should be right
Got it, sorry for taking up all this time. Just one more question
Could you please point me in the right direction for customers to renew a subscription, I wish to add a button (renew) that would use stripes checkout so they can renew that same subscription by making a new payment
So you can't use Stripe Checkout to renew a Subscription directly. What you would do is you would use Checkout in setup mode.
Then you would take the new PaymentMethod and use that to confirm the PaymentIntent
Oh so I'd have to collect the payment details for that myself, then update the customer and add it to the subscription?
If you want to use Stripe Checkout then yes that is the high level of how it is done.
Oh is that not what you meant by this?
I am currently looking at this https://stripe.com/docs/payments/save-and-reuse
I assume you're referring to this
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Nope you got the right link above. If you use the "Prebuilt Checkout page" then you would use setup mode
Since if you use Subscription mode you will start a new Subscription
I see, so I would update the customers payment method from there?
Yep you would set a new default and then attempt to charge the invoice again
Oh I see, makes sense
I think it will be best if I just allowed the customer to create a new subscription afterwards
as this will swap the default payment method for the rest of the subscriptions too
It seems like I will just create more complications trying to create this flow and end up saving the same amount of data in the end
Either way, you've enlightened me with a bunch of new information, I really appreciate all your help.