#morey-paymentmethod-attach
1 messages · Page 1 of 1 (latest)
it also shows Status : success from the response too
@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?
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
Ah, i am using: stripe.paymentMethods.attach on the backend when a payment method is created. I supposed that's not required?
yeah usually you don't need that if you configured the SetupIntent for a given customer, it will attach automatically
Ahhh
also that SetupIntent succeeded already and your code keeps trying to confirm it over and over, but it's already succeeded
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
Sure thing, ping me if you're stuck!
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)
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
and I'd use webhooks to keep things in sync https://stripe.com/docs/webhooks
Also you should never have to use the PaymentMethod Retrieve API usually
Noted! Thank you for your help! Fixed the setup_intent_unexpected_state issue too.