#rdhelms

1 messages · Page 1 of 1 (latest)

winged vectorBOT
ancient turtle
#

It should not be necessary to have a client secret with that pattern -- you'd pass the created payment method to your server t attach or use the payment method with your secret key

#

Can you say more about what you're trying to do, and what's not working like you expect?

sterile zinc
#

We want to allow customers to add payment methods without completing a payment at the same time. When we use confirmPayment, the payment method is automatically attached to the customer completing the payment, so we were hoping that createPaymentMethod would work similarly (just without processing a payment)

#

But it sounds like you're saying that after the client calls createPaymentMethod, it still has to separately pass that payment method to a server endpoint in order for the server to call Stripe.paymentMethods.attach with the newly created payment method?

ancient turtle
#

You should use setup intents for this, then, along with confirmSetup instead of createPaymentMethod + customer attach

sterile zinc
ancient turtle
#

Can you rephrase that, or provide a more concrete example of what you're trying to do?

#

If you collect payment method separately via setup intents, you can generally use those when creating subscriptions, yes

#

But you likely would not use the same flow as that doc, as the payment details are already colelcted

sterile zinc
#

We have two separate actions that a user can take.

The first action is that they can immediately upgrade, in which case we use a Payment Element with mode subscription, create an incomplete subscription (which gives us a Payment Intent with a client_secret) and then call confirmPayment with that client_secret.

The second action is that they can add a payment method (before or after having upgraded), in which case we want to still use a Payment Element and then call createPaymentMethod. But doing that alone would not connect the payment method to the customer, which is our problem.

#

When they're just adding a payment method, we don't know yet what payment plan or price or even product they might end up purchasing with that payment method

ancient turtle
#

When you say "upgrade" you don't mean upgrading an existing subscription, then, if you're creating a new one

#

The second action is that they can add a payment method (before or after having upgraded), in which case we want to still use a Payment Element and then call createPaymentMethod.
In this case, you should use a setup intent

#

A setup intent for that customer will have the payment method attached to the customer once confirmed successfully