#ironbeard

1 messages · Page 1 of 1 (latest)

honest hazelBOT
steel sonnet
#

Hi there! No, two calls will be needed. It's not possible to create a subscription and simultaneously create a customer

#

I think this is good feedback though. I can share it with our teams internally

amber kelp
#

Gotcha, thanks 🙂

#

I guess one thing I could do is create a customer when someone first adds an item to their cart (before I get actual info on them, such as email etc), and do the updating of the user info on Stripe servers later as a background task after checkout.

Can't really tell if this would be poor design though

steel sonnet
#

Just to be clear, are you using Stripe Checkout or PaymentElements?

amber kelp
#

PaymentElements, I believe. I'm passing the client_secret to the front end for the Card Element

steel sonnet
#

Got it. You can create the customer as part of your checkout process, yes. If they land on the cart and click a button to checkout, you can send them over to a form that collects info to create the customer (email address, name, shipping address if needed). Then, the next step as part of their checking out would be to create the subscription server side, and use the client_secret to present the element

amber kelp
#

Right, but really those two steps would be happening at the same time, right? They submit the form with Contact info, then 1) a Customer is created, then 2) Subscription/Invoice/PaymentIntent's client secret is created, and then the client secret sent to the front end for the user to confirm. So that step involves two calls to Stripe

steel sonnet
#

Correct, this will still require two calls

amber kelp
#

I mean, it's not so much two calls that I mind, but that both calls are happening during a single request/response cycle from the user

steel sonnet
#

Oh, sorry for not being clear. I meant you'd have either two separate pages or two separate steps on the client side: one that results in the server side call to create the customer, and a second that waits for the client secret from your server before rendering the element

amber kelp
#

But I guess I don't know what I'd display to the user in between them. They submit a form with email/name/etc, and the server gets it, and creates a Customer on stripe's servers and sends back.. ??? and then in the next request the Subscription/client secret are made and sent to the front end for confirmation with the CardElement

#

but it's all good, I think I'm okay with doing both API calls during the single request/response cycle, was just seeing if there was a way I gcould arrange it so it didn't seem to take so lon