#kun_setupintents-savedpms-defaultpm

1 messages ¡ Page 1 of 1 (latest)

hybrid plumeBOT
#

👋 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/1277698447767507017

📝 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.

tame mantle
#

This is another topic

hexed obsidian
#

Can you try to explain the issue a bit more clearly? What steps are you doing right now? What is going wrong?

hybrid plumeBOT
tame mantle
#

ok let me clear it

#

I am trying to create stripe subscription

1 first I create customer and get the customer Id
2 2nd I create subscription passing the ciustomerId and then get the client secret
3 on frontend I pass the client secrte along side with card elements and use confirmCardSetup

And hence I create the whole flow of stripe subscription

#

what if in future if my customer change its card details what I need to do?

get its paymentid and atatch to the customer thats it?>

#

any idea?

latent coral
#

Hello, once you have the payment method saved you can set it as the subscription's default payment method or the customer's default payment method depending on whether your customers can have multiple subscriptions that charge different payment methods or not
https://docs.stripe.com/api/subscriptions/update#update_subscription-default_payment_method
https://docs.stripe.com/api/customers/update#update_customer-invoice_settings-default_payment_method
A easy way to collect a new payment method would be to collect a new payment method for the customer using a SetupIntent.
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements

tame mantle
#

my customer will have one subscription at a time

#

so with which I should updated my payment method?

#

customer or subscripton

#

whats you expert opinion

latent coral
#

You can do either in that case. I probably should have explained how this works: we first check whether the subscription itself has a default payment method, if that is not set we use the Customer's default payment method. So if you have customers with just one subscription then setting either would have the same result

tame mantle
#

ohhhh got it

#

a quick question
on frontend which method I should use
to get new payment method of new card and attach ot t customer

latent coral
#

In the doc that I linked confirmSetup is the specific call where a payment method will be created if it succeeds

tame mantle
#

but what about client secret ?
and is the client secret remains the same forever? of subscription

latent coral
#

The client secret unique for each intent. The steps would be:

  1. Create a SetupIntent for this customer, pass its client secret to the frontend
  2. Confirm the SetupIntent on the frontend using the client secret
  3. Set the newly created payment method as the default for the customer or subscription
tame mantle
#

But I want the user subscription remains the same if in future he needs to updated the card details

#

in that case I think I can resue the same client secret

latent coral
#

Intents can only be used one time. Once one succeeds (or is cancelled) you need to use a new one which means using the new intent's client secret

#

To be clear, you can make multiple charge attempts on one intent. The thing that is limited is that thay can only be used until they succeed, at which point any attempt to re-use the client secret will fail because the intent is in a final state.

tame mantle
#

Let me clear my point

suppose the subscription is active and not canceled. after 6 months user want to just change its card details and keeping its subscription the same old activated.

I that case I think i should use the client secret of the this old activated subscription

tame mantle
#

??

latent coral
#

That is not how intents work unfortunately. If the intent was successfully confirmed, its client secret is not usable anymore.

tame mantle
#

ohh now that is my point

#

for new card deatils to update it
i dont want to create a new subscription I want to attach this payment method to my old activated subsctiption

and confirmCardSetup need client secret
how then I can handle it

#

any suggestions?

latent coral
#

By creating a SetupIntent directly, you do not need to create a new subscription

#

I would recommend trying to implement the flow in the doc that I linked to on a quick test page. I think that may clarify how that flow works

tame mantle
#

I went through the links but tbh they are no0t related to my question

I dont want to have future setup future payment intent

what I simply wanted is
once customer updated its card details the activated subscription he has will start using its new card details for the recurring payments

#

But the links you have provided are ambiguous not related to my question

#

If you want I can re ask my question

latent coral
#

I thought that link was relevant because it sounded like you weren't sure how to save new payment methods to attach to the subscription

tame mantle
#

The point still remains there

on frontend confirmCardSetup needs a client secret for the time I want to use new payment method

and the client_secret is coming from the creation of subscription
which I dont want

latent coral
#

The doc that I sent you shows how to create a SetupIntent and use its client secret

tame mantle
#

furthermore
customer or subscription will update once
i have new payment method from confirmCardSetup

latent coral
#

I am sorry I don't know how but we just keep talking past each other

tame mantle
tame mantle
latent coral
#

You need to use a SetupIntent here. There is no other alternative.

#

SetupIntents are a suppliment here, they don't replace or in any way negatively impact the subscriptions that you otherwise have

tame mantle
latent coral
#

SetupIntents are what you use when you want to save a PaymentMethod when you aren't also taking a payment

#

You can use a setup intent to create a payment method and can then set that payment method as the default for the subscription

#

That is the purpose of setup intents. To save payment methods to be used for other things

tame mantle
#

Now I got it and its much clear

#

can I re confirm it?

#

Once I need to update the card details .

step 1: create setup intent so i can get client secret
step 2: use this client secret with confirmCardSetup to get new payment method

step3 : update the customer with this new payment method so that my activated subscription start using the new card details

am I right?

#

and Please provide me the url for creating setup intent so I can update my card details

latent coral
#

Yep that is the correct process. Happy we are on the same page. This is the specific step in the doc that shows creating the setup intent
https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements#create-intent
And here is the API ref page on creating setup intents
https://docs.stripe.com/api/setup_intents/create

Learn how to save payment details and charge your customers later.

tame mantle
#

now the flow is clear

#

What i learnt today
if I want new payment method
setupintent is for it

#

a quick question
on frontend I should use confirmCardSetup right?
and will setupintent send client secret key?

latent coral
#

You will want to send your setup intent client secret to the front end before calling confirmCardSetup. The confirmCardSetup call requires a client secret

hybrid plumeBOT
tame mantle
#

thansk for the help really appraciate it

latent coral
#

Of course, glad I could help!

tame mantle
#

Have a nice day