#andy_best-practices

1 messages ¡ Page 1 of 1 (latest)

severe templeBOT
#

👋 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/1332355693180616876

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

dense vortex
#

Is there a way to automatically create a new Stripe Customer when the Stripe Elements form is submitted?

analog prairie
#

No. But you can make a Stripe API call from your backend at that point and create the Customer

#

In your frontend submit function, you make an API call to your backend which well create the Stripe Customer.

dense vortex
#

Shouldn't this happen after the SetupIntent has succeeded (therefore, asynchronously)?

#

Since it's a No, does my plan below fall under the Best Practices category?

T+0 - user submits the form
T+1 - user is redirected to some "Please wait" page that keeps polling for the new payment method
T+2 - stripe sends the setup intent event to the webhook endpoint
T+3 - read the event, create a new Stripe customer, associate the payment with the customer
T+4 - user sees the new Payment Method added to their account

analog prairie
#

Actually you can preview the Element and submit the payment before creating an intent

severe templeBOT
dense vortex
#

Hm. From the link you shared, it's not clear when the server is invloved.

#

Well, Step 4 says:

Create a Customer object when your customer creates an account with your business

But that's what I'm trying to avoid - polluting the Stripe Customers database. Who is calling the Step 5? I could potentially create a new customer during this step.

remote lichen
#

You can wait to create the customer until step 5

#

right before you create the setupintent

#

That would be called when the form is submitted