#arrowcircle
1 messages · Page 1 of 1 (latest)
What do you mean? Can't you just check the client reference id on the checkout session object: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-client_reference_id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I added this, and it returns on session success, but will it be sent on charge_succeeded or charge_failed?
No. It's only attached to the session object
If you listen for payment_intent.succeeded instead of charge.succeeded (which is recommended anyway) you can make an additional api call to list checkout sessions by payment intent: https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent to get your session and client reference id
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
this means I need to store all the payment_intents ids, that will not have client_reference_id?
and how it differs from charge.succeeded?
Payment Intents are the newest version of charges
They're build on top of charges
So you'll get a payment intent object not a charge object
It's up to you though
I just suggested you use that instead of charge because there's an easy way to link it to the checkout session so you can get the client reference id via the api endpoint above
I still dont get it, If initally I create payment session and add client_reference_id, will it be sent with webhooks about payment_intents in the future of the subscription?
And do I get it rights, it's better to listen payment_intent webhooks instead of charge events and checkout session?
Oh these are for subscriptions
Ok let me suggest something different then
When you initially get a checkout.session.completed event, the event will contain both the subscription id and the client reference id: https://stripe.com/docs/api/checkout/sessions/object. So, once you get that event, I recommend storing a mapping of subscription id -> client_reference_id in your database. Then for future payments, listen to invoice.paid. Really I recommend reading this whole doc to understand subscription events + webhooks before asking further questions: https://stripe.com/docs/billing/subscriptions/webhooks. With invoice.paid, you will get an event when each subscription invoice is paid for every billing cycle. On that invoice object, you can get the subscription: https://stripe.com/docs/api/invoices/object#invoice_object-subscription and then just check your database for the subscription -> client_reference_id mapping to identify the customer.