#pedro-reis_api

1 messages ¡ Page 1 of 1 (latest)

pseudo charmBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1310556948755775560

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

untold sundial
#

I've tried to update the subscription setting trial_end: 'now' but the subscription was being cancelled straightaway

granite turret
#

Hi, let me help you with this.

untold sundial
#

a colleage last week suggest updating the subscription with trial_end: 'now' and get the pending_setup_intent

granite turret
#

the subscription was being cancelled straightaway
Do you know why is this happening? If you're collecting the PaymentMethod via Subscription's client_secret it will be charged for the Subscription's Invoices.

#

Or is the client_secret coming from the new Subscription you're creating?

untold sundial
#

while adding the subscription to the user for the first time, these are the settings I'm passing to stripe.subscriptions.create:

{
customer: customerId,
trial_period_days: 7,
payment_behavior: 'default_incomplete',
payment_settings: {
save_default_payment_method: 'on_subscription',
},
trial_settings: {
end_behavior: {
missing_payment_method: 'cancel',
},
},
}

granite turret
#

The last parameter explains why it's cancelled when you end the trial.

untold sundial
#

yeah, I guessed that

#

I need the subscription to be cancelled after the trial if the user does't add their payment details

#

what's the best way to achieve this?

granite turret
#

That's already achieved, it seems. I understand that you actually need to not cancel it if the PaymentMethod is added, right?

untold sundial
#

yes, exactly

#

so :

  1. if the user does not add their payment details, the subscription is cancelled (done!);
  2. I need the trial to end and make the subscription Active if the user adds their payment details
granite turret
#

Or is the client_secret coming from the new Subscription you're creating?

#

Where is the new PaymentMethod saved?

untold sundial
#

I'm using the stripe.confirmSetup on the frontend

#

I was trying to call stripe.subscriptions.update on the backend and get the client secret (from the pending_setup_intent suggested by your colleague) from that call and pass it to the stripe.confirmSetup

granite turret
#

Could you please share and example Subscription ID?

granite turret
untold sundial
#

sorry, but what should I fetch with the get? and where should I pass it? to the Elements options?

granite turret
#

Whenever you want to let a customer add their PaymentMethod, you can fetch the trialing Subscription by ID, grab the pending_setup_intent.client_secret and pass it to the Payment Element.

untold sundial
untold sundial
#

actually, no... you said to pass the secret to the Payment Element options?

#

or should I pass it to the stripe.confirmSetup()?

#

I'm really sorry for all the questions and really appreciate your help on this!

granite turret
granite turret
untold sundial
#

ok, I think I got it

#

last question to make sure I understand everything: the pending_setup_intent is created while creating the subscription for the first time, correct? then we just need to grab it to update the payment details before updating the subscription/ ending the trial and make it active

granite turret
#

Yes

untold sundial
#

ok

granite turret
untold sundial
#

ok, I'll have that in mind

#

thank you very much! I will try your suggestions

granite turret
#

Happy to help.

untold sundial
#

I believe there's no way to get back to this thread once closed so it's easier to recover the conversation?

#

in case I have further questions

granite turret
#

You will be able to view it, but you will need to create a new one if you have more questions. I might not be around at that time anyway.

untold sundial
#

yeah, of course! thank you once again, vanya