#gecko-Checkout-URL
1 messages · Page 1 of 1 (latest)
Hi there! Yes you want to use Webhooks! There are times where your customer may complete payment but not make it to your redirect URL (imagine they are on a train and enter a tunnel right as they hit "pay"), so you don't want to rely on the redirect for fulfillment/transaction data.
Ok so I could get a success URL returned, and the payment doesn’t actually succeed?
No, but you could have a successful payment and the success URL is never hit. That is why you want to rely on webhooks
ok
so....here's my next question
right now, I have an integration with checkout in my page. i create the session, and I have a bunch of customer info inside my page. this is all transaction-specific, which I can't send through the checkout session.
I will then get a webhook at some later time, which shows a successful payment.
but I can't link the two halves together....or rather, how is this done? is there a transaction ID from the session creation, that I can harvest, so I can match it up with the webhook later?
if not, how to do this???
Have you taken a look at our docs on this? https://stripe.com/docs/payments/checkout/fulfill-orders
That walks you through how to use webhooks with Stripe Checkout!
so that's all the webhook side for processing the transaction....which I can do, yes....but it's not my question.
Those webhooks will have all the data you want though, no?
let me try it differently. suzie goes to my site, and logs in as suzie. she orders a t-shirt. I create a checkout session. it redirects to stripe's site, and she fills out her personal info, makes payment etc.
Sorry, to be clear, you would fetch the PaymentIntent after to access your metadata
then I get a webhook, that shows a customer email, but I don't know if it's suzie or someone completely new, not in my DB yet
but I knew it was suzie, before redirecting her to stripe checkout.
the webhook doesn't tell me that this transaction completion is for suzie or someone else
So most people handle this by authenticating their customer ahead of the Checkout Session
So you would associate suzie with a Customer ID
i have a customer id
And authenticate them via a login
but....that ID doesn't go to stripe, and back through to the webhook
so you're saying I have to rely on email as the common thread between the front end and back end of the transaction? no other way?
No, you would set metadata to link them.
how
Definitely don't just rely on the email, as that can be duplicated
You can set metadata on any object you want -- in this case it sounds like you want to set metadata on the Customer object itself
So associate Suzie
how to create metadata that flows through?
I had asked about this originally many weeks ago was told I couldn't send data across stripe this way, because it could be compromised.
Yeah so these metadata attributes would not all flow through to the webhook. However, you would set them and then retrieve the relevant objects. Like the customer ID will show up associated with the Checkout Session and the PaymentIntent.
explain how this works please, or show me a reference?
Suzie logs in to your site and has cus_123 and you set metadata on your end as you wish. She wants to make a payment so you pass cus_123 to the Checkout Session creation. On this Session Creation you can also add metadata about the specific order. Payment succeeds. You get a webhook with the Session ID, the PaymentIntent ID, the Customer ID. You can then retrieve any of these objects to get further info or see the associated metadata.
fantastic....so ID's can flow through the payment process to the webhook
🤦🏻♂️
what/how do I attach this info, to a session creation?
Yes, sorry I didn't make that clear earlier!
You pass the Customer ID on session creation: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
this "customer", in the docs, I assume refers to the customer details that Stripe stores, not my business's customer ID...correct? (the way this part of the docs reads, it looks up the ID and if it finds it, then it's pre-populates payment info)
ahh....meta-data key-value pairs....this is the spot?
Yes
The Customer ID above is Stripe's customer ID
You want to use metadata to associate this customer to your own business's customer ID
So that you can track
ok so I see it's a key-value pair...is it the same style as line_items, and is an array of key/value objects? (meaning I can send an arbitrary number of array elements inside the array?) the documentation doesn't specify meta-data format in the description and isn't in the example code to the right either.
Hello! Yep, metadata in Stripe is an array of key/value pairs. You can have up to 50 keys. More details here, including example code: https://stripe.com/docs/api/metadata