#HugoRS
1 messages · Page 1 of 1 (latest)
Can you elaborate?
Hey! We are doing one-time payments with the checkout api call
In our backend, we are listening for the charge.succeeded webhook. However, this doesn't seem to give us the quantity
We could get the object_id which is "ch_3NAeZ7GNjb0e7sHd1XoUI7xV". And when retreiving that checkout, I get the error: No such checkout.session:
That's correct, Charge objects do not include line-level details. The ID that you shared is for a Charge, so it is expected that you won't be able to retrieve a Checkout Session with that ID. Checkout Session IDs will start with a cs_test_ prefix for testmode, and cs_live_ for livemode.
Would listening for checkout.session.completed Events work for your flow? That would provide you with an Event that contains the ID of the Checkout Session that you could use to retrieve the associated line items:
https://stripe.com/docs/api/checkout/sessions/line_items
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 am just worried that checkout.session.completed is also listening when a user subscribes to one of our plans
Will this also trigger when a user subscribes to a plan via the checkout?
Yup, it is triggered whenever a Checkout Session is completed.
Can I use the event id somehow to get the quantity? "evt_3NAeZ7GNjb0e7sHd1vsgSR84",
Or payment_intent": "pi_3NAeZ7GNjb0e7sHd1Kj2U8MA"
That Event is being slow to load for me, what type of Event is it? Payment Intents also do not hold line-item information, that is stored on the Checkout Session's line items. If you have the Payment Intent you can use it to find the associated Checkout Session by listing the sessions associated with that Payment Intent:
https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent
but you can't get the line quantities directly from the Payment Intent.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Is this: pi_1JGFa64XsdaddaBSbwSJtEu2 a checkout session id?
No, it's a Payment Intent ID (the pi_ prefix indicates Payment Intent). Checkout Session IDs will start with a cs_test_ prefix for testmode, and cs_live_ for livemode.
But I can't seem to find the checkout session id from payment intent (https://stripe.com/docs/api/payment_intents)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Did you use the function I linked here to list Checkout Sessions and provide the ID of the Payment Intent as a filter to the list request?
How can I filter this in the api call?
Pass the ID of the Payment Intent as a string to the payment_intent parameter.
Works like a charm! Thank you
Any time!