#Pain - trigger a subscription payment

1 messages · Page 1 of 1 (latest)

bold whale
#

Yes that is one of the events that is generated .We actually have two ways for you to test this quickly:

#

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

golden raft
#

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

bold whale
#

Nice! Glad we have something for you there

golden raft
#

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?

bold whale
#

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?

golden raft
#

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

bold whale
#

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.

golden raft
#

Those are the ones that I am listening to currently

#

The query execution is the invoice.paid event

golden raft
#

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

bold whale
#

Yes those events are created and you can see when the subscription moves to past_due

#

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

golden raft
#

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

bold whale
#

Can you tell me a bit more about the flow that you want here?

golden raft
#

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?

bold whale
#

I think that should make the subscription go to past due as soon as the first payment happens

golden raft
#

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?

steady crescent
#

👋 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?

golden raft
#

I wish for it to happen as soon as a payment fails

#

I believe I almost have it

steady crescent
#

Okay so just to be clear... if the first payment fails when you start a Subscription, that Subscription will expire in 23 hours.

golden raft
#

Oh

#

What if I change this setting?

steady crescent
#

No that is for renewals

golden raft
#

After I changed it the subscription didn't get cancelled anymore

#

I attached the card that fails

steady crescent
#

Sure, see how the first payment was successful?

golden raft
#

Yes,

steady crescent
#

So if that one fails

#

Then the Sub will expire in 23 hours

golden raft
#

So only if the first payment fails?

steady crescent
#

Correct.

#

You can get around this by setting a trial on the Sub

golden raft
#

Okay so that's fine, I only save it if the first payment succeeds

steady crescent
#

Then the first payment will always succeed

#

Okay that works

#

Just wanted to clarify

golden raft
#

Got it, I want to do it after that payment

steady crescent
#

Sounds good

golden raft
#

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

steady crescent
#

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

golden raft
#

This is the right setting?

#

I wish to cancel the subscription after 7 days

#

If it isn't paid

steady crescent
#

No that is for 3DS confirmation

golden raft
#

Oh

#

Sorry misread

steady crescent
#

You want to adjust the settings under "Manage failed payments"

golden raft
steady crescent
#

Yep you want to change those settings

golden raft
#

That would cause it to cancel the subscription as soon as it fails the first time

steady crescent
#

Correct

golden raft
#

I don't wish to cancel it straight away

steady crescent
#

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

golden raft
#

Oh I see

steady crescent
#

Alternatively, you could just retry again at 7 days and if that fails then cancel.

#

Then you can use the settings to cancel

golden raft
#

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

steady crescent
#

Yep that should be right

golden raft
#

Got it, sorry for taking up all this time. Just one more question

steady crescent
#

No need to apologize!

#

That's what we are here for!

golden raft
#

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

steady crescent
#

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

golden raft
#

Oh so I'd have to collect the payment details for that myself, then update the customer and add it to the subscription?

steady crescent
#

If you want to use Stripe Checkout then yes that is the high level of how it is done.

golden raft
#

I assume you're referring to this

steady crescent
#

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

golden raft
#

I see, so I would update the customers payment method from there?

steady crescent
#

Yep you would set a new default and then attempt to charge the invoice again

golden raft
#

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.

steady crescent
#

You can set defaults at the Subscription or Customer level

#

So really up to you on how you want to handle

#

But starting a new Subscription works too!