#Ralph-checkout-fulfillment
1 messages · Page 1 of 1 (latest)
Single Page application
So here's the specific question:
I have a webhook configured and making a POST to my server correctly, but I'm unsure of how to confirm which actual USER completed the checkout process when the webhook activates
Yeah so I can get the dealership account and that's good because I can then update the information there
But for which specific USER (ie. customer) completed the checkout process, I'm at a bit of a loss
Oh, not your Connected Account user, the end-customer themselves.
the session will return the users e-mail, but there's a case where they input a different e-mail than their account e-mail
Got it. Are you using Stripe Checkout?
YEah
This is an example response I get from the webhook:
{"id":"cs_test_a1CSJgbhp7hOiOVvKBH1tOWBkzWluSnjRol4jBlyLRHckmPwXNcCg8kD2q","object":"checkout.session","after_expiration":null,"allow_promotion_codes":null,"amount_subtotal":201600,"amount_total":201600,"automatic_tax":{"enabled":false,"status":null},"billing_address_collection":null,"cancel_url":"http:\/\/localhost:8080\/honda\/9999","client_reference_id":null,"consent":null,"consent_collection":null,"currency":"cad","customer":"cus_LRr3pW5qsxYRj5","customer_creation":"always","customer_details":{"address":{"city":null,"country":"CA","line1":null,"line2":null,"postal_code":"N2Z 0C6","state":null},"email":"ralph@shopdesk.io","name":"Ralph Barac","phone":null,"tax_exempt":"none","tax_ids":[]},"customer_email":null,"expires_at":1649193691,"livemode":false,"locale":null,"metadata":[],"mode":"payment","payment_intent":"pi_3KkxL5QhG88walQ21Z5chOz0","payment_link":null,"payment_method_options":[],"payment_method_types":["card"],"payment_status":"paid","phone_number_collection":{"enabled":false},"recovered_from":null,"setup_intent":null,"shipping":null,"shipping_address_collection":null,"shipping_options":[],"shipping_rate":null,"status":"complete","submit_type":null,"subscription":null,"success_url":"http:\/\/localhost:8080\/honda\/9999\/checkout-successful","total_details":{"amount_discount":0,"amount_shipping":0,"amount_tax":0},"url":null}
Sorry it's terribly formatted, but the important bit is obviously I do get the e-mail the customer uses
Which I CAN cross reference with the dealership they purchased from
But they can input an e-mail that is not the same as their account e-mail on our website
Got it. So there are a couple options here.
Is there a way to pass extra information to the Stripe session object so that when it returns I get the user associated?
Yep
One of the options is to pass your own metadata
Which will be returned after the session is completed
What are the other options?
The other option is to use a Stripe Customer object and either pass one into the Session or have the Session create one.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
OK the first option is definitely better for my use case I think
I figured something like that was available I just couldn't find it
I'd like to leave this thread open for an hour or so in case I have issues but otherwise thanks for your help!
can I add metadata to this call:
$session = \Stripe\Checkout\Session::create([
'payment_method_types' => ['card'],
'line_items' => $products,
'mode' => 'payment',
'success_url' => $successURL,
'cancel_url' => $returnURL,
], ['stripe_account' => $dealer->stripe_account_id]);
Yep
That is the one you would add it to
And I'll leave the thread open for a while! Feel free to come back with any more questions
Are you passing metadata like we show here: https://stripe.com/docs/api/metadata?lang=php?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yeah I've fixed that issue. One last question, is there a way to pass along this information when I redirect from the stripe checkout to the success_url?
No you have to pass it on Session creation if you want to pass it yourself. Only the information from the completed session will be returned once the success_url is hit.