#Bob-paymentMethod

1 messages · Page 1 of 1 (latest)

gloomy yoke
#

Hi Bob, may I know when do you want to convert a token to payment method? How about using payment method API directly?

opal ridge
#

It's out of convenience. So that the setupintent is created only after details have been provided, instead of before.

  1. collect details using Elements
  2. Pass the token to backend to create the payment method
gloomy yoke
#

Is there anything that preventing you from creating the SetupIntent up front?

opal ridge
#

Its more complicated to achieve the same UX

#

It can be done with card tokens. But the same structure doesnt work with sepa

gloomy yoke
#

Maybe you can walk me through your current flow, it's be great if you can also share with me some codes

opal ridge
#

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?

gloomy yoke
#

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.

opal ridge
#

Right. But thats only if setupintent is created before collecting the details?

gloomy yoke
#

Yes, you need to create a SetupIntent, and use the clientSecret to render the Stripe payment elements

opal ridge
#

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.

gloomy yoke
#

No problem. I'll recommend to consider using the new API/workflow to make your integration future proof 🙂