#kryze_

1 messages ยท Page 1 of 1 (latest)

mighty scrollBOT
plucky sapphire
#

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 to checkout.session.completed event, 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 from invoice -> payment_intent -> List Checkout Session using payment_intent parameter
https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent

austere gate
#

Okay, there is not possibility to put the Metadata somewhere more easily accessible ?

plucky sapphire
austere gate
#

Its a one payement not a sub ! ๐Ÿ™‚

plucky sapphire
#

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

austere gate
#

Yes, looking into it right now thank you !!

plucky sapphire
#

๐Ÿ‘

austere gate
#

And do you know what is th best way to check if a metadata field exist ?

#

In ruby

plucky sapphire
#

As in? On an object?

#

obj.metadata !== nil right?

austere gate
#

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({

plucky sapphire