#mattsulima
1 messages ยท Page 1 of 1 (latest)
For metadata set on the Payment Link, it doesn't get populated into Payment Intents (the payment page in the dashboard). Metadata will only be populated to Checkout Session created by Payment Link.
From https://stripe.com/docs/api/payment_links/payment_links/create#create_payment_link-metadata:
Metadata associated with this Payment Link will automatically be copied to checkout sessions created by this payment link.
To add metadata to the Payment Intent, it can only be done after payment is completed with Payment Intent created: https://stripe.com/docs/api/payment_intents/update#update_payment_intent-metadata
Thank you. Is there any way to get checkout session object having charge id? Charge id e.g. ch_xxxxxxxx
Yes, it possible to get Charge ID using Checkout Session retrieval API with expanding payment_intent:
- Checkout Session retrieval API: https://stripe.com/docs/api/checkout/sessions/retrieve
- Expanding: https://stripe.com/docs/api/expanding_objects
payment_intentparam: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-payment_intent
After expanding payment_intent, you'd find charge ID in latest_charge or charges.data depending on the API version you use: https://stripe.com/docs/payments/payment-intents/verifying-status#identifying-charges
Okay, sounds promising. Thank you very much!
No problem! Happy to help ๐
hello again! ๐ I am testing above, and it looks my biggest problem is thatI don't have checkout session id. Like mentioned, I have charge id, I can get payment intent, but how to get checkout session from it?
Everytime when a payment is completed successfully, Stripe will send checkout.session.completed to your webhook URL which will include Checkout Session ID: https://stripe.com/docs/payments/payment-links/api#tracking-payments
What if we don't use webhooks? ๐ We only have csv files - we use dashboard -> all transactions -> export
and I planned to use an API to get all metadata for single charge
I'm afraid that it's not possible to get Checkout Session from the Charge ID. Listening to the webhook is the only way to get the metadata set in Payment Links/Checkout Session
Okay, thank you!
Hi! If you have a Charge ID, you can retrieve the Charge to find the PaymentIntent ID https://stripe.com/docs/api/charges/object#charge_object-payment_intent
Then once you have the PaymentIntent ID, you can find the corresponding Checkout Session with https://stripe.com/docs/api/checkout/sessions/list and passing the PaymentIntent ID.