#swe_api

1 messages ยท Page 1 of 1 (latest)

mystic terraceBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1374851954265559071

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

native quiver
#

Hi there! Do you mean that you want to create a SEPA payment method that can be used later, while collecting those payment method details on Stripe Elements?

tardy forum
#

No, I am not using Stripe elements.

#

I am using Stripe.js and I have my own UI components.

#

Yes, I want to create a SEPA payment method, that can be used later.

native quiver
#

Let me look into that - I'm not certain whether you can create SEPA payment methods using Stripe.js without Elements

tardy forum
#

Sure, thank you. We have been usng this flow in sources API.

  1. Create token using bank details
  2. Use the token in sources API to create source. But, now sources is deprecated
native quiver
#

testing this - sorry, typed that out and forgot to send

tardy forum
#

Thank you so much for your assistance. This is very critical to us at this hour.

native quiver
#

and when the SetupIntent is confirmed, you'll receive a pm_ object that you can charge later according to your agreement with your customer

tardy forum
#

Nope, I just created from the server for testing purpose. But, in real word scenario, we will create the token from the front end.

#

We'll be using the corresponding JS API.
This is our current flow:

  1. Use tokens API in Stripe JS (client-side) to tokenize the bank account. API used - https://docs.stripe.com/js/tokens/create_token?type=bank_account
  2. The token is then used in Stripe REST API (server-side) to create SEPA direct debit source. API used - https://docs.stripe.com/api/sources/create

But, now with sources deprecation, we would appreciate some alternative approach here.

native quiver
#

gotcha. So I think what you're going to need to do is just create a PaymentMethod on the client, and then you'll create & confirm a SetupIntent and pass that PaymentMethod to it

#

testing that

tardy forum
#

Sure, please send me the code snippet that you try. I'll also try that parallely.

#

Btw, we do not want to use Stripe elements here

native quiver
#

yep

#

so you would do something like this:

#

const paymentMethod = await stripe.createPaymentMethod({ type: "sepa_debit", sepa_debit: { iban: "DE89370400440532013000", }, billing_details: { name: "Jenny Rosen", email: "jennyrosen@example.com", }, });

and then from that you would get a pm_123 which you would then pass to your server and create/confirm a SetupIntent

#

Yeah I see the docs are slightly wrong here where they say "Use stripe.createPaymentMethod to convert payment information collected by elements into a PaymentMethod object that you safely pass to your server to use in an API call."

#

that would be for creating a PaymentMethod with Elements

tardy forum
#

I will try this out right away, could you not close this thread, till then?

native quiver
#

Sure

tardy forum
#

Will this work in live environment? I see GPT saying that it will not work in live without elements. Can you confirm this?

native quiver
#

๐Ÿ˜•

#

if you look in the docs you'll see that we provide an option for providing an iban or an iban element

#

The llms don't know everything yet

tardy forum
#

Amazing, the snippet worked just fine, and thank you so much for this.