#kryze_
1 messages ยท Page 1 of 1 (latest)
Hello ๐
In my application I have two types of payment, one is Reservation, the other is a Shop. How can I tell my webhook that one type of Session is for Reservation and the other is for an Order and to do different things (For exemple after the paiement, the reservation should be marked as done in my db and for an order it should mark it as "Preparing the order'
if you're mapping client_id or order_id to either reservation or shop in your database then what you'd want to do is listen tocheckout.session.completedevent, when you receive the event look at the metadata and make a request to your DB to see what type of checkout it was.
The other question is, how can I access metadata from a Checkout Session inside the invoice.payment_succeeded ?
I don't think there's a straightforward way to do this. I believe you'd need to go frominvoice->payment_intent-> List Checkout Session usingpayment_intentparameter
https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent
Okay, there is not possibility to put the Metadata somewhere more easily accessible ?
The other option would be to set it on the subscription itself
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-metadata
Its a one payement not a sub ! ๐
Ah in that case, you can set the metadata directly on the invoice by using checkout.invoice_creation.invoice_data.metadata
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-invoice_creation-invoice_data-metadata
That metadata would then be set on the invoice object which is delivered via invoice.payment_succeeded & invoice.paid events
Let me know if that helps @austere gate
Yes, looking into it right now thank you !!
๐
Yes ! ๐
Sorry if I ask too much questions but is it possible to add the metadata to the invoice.payement during @session = Stripe::Checkout::Session.create({
yes. I shared the doc reference above on how
You'd want to set invoice_creation.invoice_data.metadata when you create a checkout session
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-invoice_creation-invoice_data-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.