#Bob-paymentMethod
1 messages · Page 1 of 1 (latest)
Hi Bob, may I know when do you want to convert a token to payment method? How about using payment method API directly?
It's out of convenience. So that the setupintent is created only after details have been provided, instead of before.
- collect details using Elements
- Pass the token to backend to create the payment method
Is there anything that preventing you from creating the SetupIntent up front?
Its more complicated to achieve the same UX
It can be done with card tokens. But the same structure doesnt work with sepa
Maybe you can walk me through your current flow, it's be great if you can also share with me some codes
Passing the setupintent secret to frontend is bit of an annoyance. So for card payments after the details are entered we pass the token to backend and create a payment method:
'type' => 'card',
'card' => [
'token' => $token,
],
],```
Now, we have a use case where we need to add a sepa DD too. But using the same structure, there's an error
```Received unknown parameter: payment_method_data[sepa_debit][token]```
payment_method_data is less than documented. I dont know if for sepa there's a different structure, or its not supported at all?
Thanks for the info and waiting. If you use SetupIntent API. the paymentMethod will be implicitly created by Stripe and attached to the customer, so you don't need to explicitly call the PaymentMethod creation API.
Right. But thats only if setupintent is created before collecting the details?
Yes, you need to create a SetupIntent, and use the clientSecret to render the Stripe payment elements
Hoped to use the same workflow as for cards, but can do that too.
More of a preference than a technical limitation.
Thanks for the information.
No problem. I'll recommend to consider using the new API/workflow to make your integration future proof 🙂