I’m implementing Stripe checkout on a website and I want to pass some specific data on checkout.session.complete. Here is what I tried:
'mode' => 'payment', 'payment_intent_data' => [ 'metadata' => [ 'eventId' => $eventId, ], ],
But I don’t receive those datas in my webhook. What am I doing wrong ?
Advertisement
Answer
payment_intent_data
gets added to the resulting PaymentIntent
object, not the CheckoutSession
object. It won’t be present in the checkout.session.complete
webhook data you’re sent.
(The PaymentIntent
‘s ID will be, so if you like, you could request that object’s data as part of your webhook processing. You could also collect the payment_intent.created
webhook type, but you’d have to correlate it after the fact with the session.)
The easier approach here is probably setting a client_reference_id
on the Checkout Session. This ID is passed back via the webhook, and can be any arbitrary string you like – it could be a session or cache key that let you look up the metadata you’re looking for.