Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you match a Stripe Checkout to a charge.succeeded webhook?

We are using the Stripe Checkout and setting our metadata when we create the Session. This allows us to catch the checkout.session.completed webhook and that webhook contains the metadata.

However, we also use Sources, like WeChat, and these are not handled by the Stripe Checkout. To use WeChat, we create a Source and when the user confirms via the QR code, we charge it.

We want to use the charge.succeeded webhook as a central place to fulfil orders, regardless of where they come.

The issue is that the charge.succeeded webhook generated from a successful Stripe Checkout does not contain any of the Session metadata we set, so we can't link it to a Checkout Session and hence have no idea what it relates to

The only way we can see how to do this is:

Stripe Checkout

Catch the checkout.session.completed webhook and use the included metadata to fulfil the order. For the customer details, we can call the Payment Intent

WeChat (And other sources)

Catch the charge.succeeded webhook which contains both the customer data and the Source, which contains the metadata.

like image 404
Colin Avatar asked Oct 31 '25 12:10

Colin


1 Answers

The Charge object will have a payment_intent and you can list CheckoutSessions by that PaymentIntent's id.

Alternatively, you can also set the metadata directly on the PaymentIntent when creating the CheckoutSession.

like image 50
taintedzodiac Avatar answered Nov 03 '25 10:11

taintedzodiac