How to update user credentials after setupIntent succeed in Stripe API (Node.js + React)

53 Views Asked by At

I have scenario where users setting their payment credentials in Profile setting page using PaymentElement (mostly simple card detaild number, year, cvv). Before that I bind customer (user) with new SetupIntent (on successful signup) and then send secret from them for Elements (wrapper around PaymentElement) in Profile setting page. I want to get ability that users can change/update/delete their payment credentials. I tried to change SetupIntent but it prevents changed due to 'success' status. How to make it in proper way?

  1. user sends POST request on completion of sign up
  2. then on backend I make stripe.customers.create -> stripe.setupIntents.create(customerId) -> save setupIntent id in db
  3. user signed in into account, opens settings page with stripe PaymentElemets
  4. client requests to get client_secret (from back using setupIntents.retrieve(id)) for Elements (around PaymentElemets)
  5. user fills payment details -> stripe.confirmSetup (on client) -> setupIntent becomes 'success'
  6. ...then, I wonder how to handle case user want to change payment credentials in proper way.

all according to official doc tutorial https://docs.stripe.com/payments/save-and-reuse?platform=web&ui=elements#set-up-stripe.js

1

There are 1 best solutions below

5
RyanM On

It is unclear what you mean when you say "change payment credentials". However, once a Payment Method of type "card" is saved, you can only update the expiration data and networks as the API reference doc shows.

If the user wishes to change the card number you must create a new Payment Method.