#morey-paymentmethod-attach

1 messages · Page 1 of 1 (latest)

celest rover
next dock
#

it also shows Status : success from the response too

celest rover
#

@next dock the flow usually is this
1/ Create a SetupIntent server-side with a customer
2/ Confirm the SetupIntent with Elements

#

that's all

#

Do you have an example request id (req_123) that I can look at to explain the invalid state?

next dock
#

Ya moment

#

req_MUAnQAkyohxnJL
here it is!

celest rover
#

that request has a clear error message. It says you're trying to attach that PaymentMethod to a customer after the fact and I'm not sure I understand what you're doing there. The SetupIntent can do that for you automatically

next dock
#

Ah, i am using: stripe.paymentMethods.attach on the backend when a payment method is created. I supposed that's not required?

celest rover
#

yeah usually you don't need that if you configured the SetupIntent for a given customer, it will attach automatically

next dock
#

Ahhh

celest rover
#

also that SetupIntent succeeded already and your code keeps trying to confirm it over and over, but it's already succeeded

next dock
#

your code keeps trying to confirm it over and over
that's probably an inefficiency on my code.

#

Alright, I think i know where to go from your feedback now :D... Let me give it another try

celest rover
#

Sure thing, ping me if you're stuck!

next dock
#

Ah I do want to also ask, is it generally considered safe to store the results from stripe.paymentMethods.retrieve( paymentMethodId );

On my database too?

#

or pull that data from stripe everytime (for customer cc management)

celest rover
#

I'd store the information that I care about if it were me. It's best to not have to do a GET every time you need info

#

Also you should never have to use the PaymentMethod Retrieve API usually

next dock
#

Noted! Thank you for your help! Fixed the setup_intent_unexpected_state issue too.