#Loren
1 messages · Page 1 of 1 (latest)
Hi there
You added: (Obviously I can stick metadata into the payment_intent when I first create it, but that is before the user has filled out the fields since I need the payment_intent to create the element to just show the fields to begin with)
The most common way to capture name/email/phone would be through Billing Details with confirmPayment(). However you can't pass other metadata client-side as that would be a security issue. You should instead pass that data to your server and update the PaymentIntent server-side to set that metadata
Thanks. I tried setting billing_details but that data never appeared on the other end of the webhook so I assumed it was broken. should it work?
Yeah it gets stored on the PaymentMethod object
So when you receive payment_intent.succeeded you can retrieve the PaymentIntent and expand the latest_charge and then look at the payment_method_details
Otherwise you can just retrieve the PaymentMethod directly and see that data
Got it, so I've got 2 options, stick what I can in billing_details and make an extra API call on the webhook end of things to expand out the data, or make an extra API call on client submit to update the metadata server-side, then process the transaction. If I go with option #2, does it make the most sense to update the metadata and confirm the payment at the same time (both server-side) rather than bouncing back to the client to confirm the payment?
Well let's back up a moment
When do you actually collect this data?
Before you render Payment Element?
Also are you using the standard Payment Element flow (pass the client secret to the client to render Payment Element) or are you using the deffered intent flow?
The fields are next to the payment element (one screen with the card element and few fields I control)
Yes, standard element flow (pass the client secret to the client)
I don't know what the deferred intent flow is, but maybe that would be useful here?
Yep take a look at https://stripe.com/docs/payments/accept-a-payment-deferred
With that flow you can just set the metadata when you create your PaymentIntent as you have to call your server for that anyway
Only downside of deferred intent really is that there are a few payment methods that we are still working on fully supporting in that flow (like ACH)