#canadiancow
1 messages · Page 1 of 1 (latest)
client_reference_id only exists on Checkout Session object and it can't be found in Payment Intent.
One way I can think of is to:
- Search the succeeded Payment Intent
- Find the Checkout Session associated to the Payment Intent by setting
payment_intentin the List Checkout Session API: https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent
Alternatively, you can set the value of client reference ID in the payment_intent_data.metadata when creating the checkout session, so that it will be available in Payment Intent: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
Unfortunately I'm just using payment links, so I'm not sure I can do that. My user-facing payments are pretty basic, but I was hoping to do some reporting without having to do one query per payment.
However, my goal is to have a webhook to handle everything as it happens, whatever that takes.
So for now, based on my current basic implementation, I guess it's one lookup per payment.
Thanks!
Yup! Alternatively, you can listen to checkout.session.completed event that will be sent when it's completed successfully. The event will include the client_reference_id which you can save those records in your database and search them within your database later