#HugoRS

1 messages · Page 1 of 1 (latest)

thorny minnowBOT
tropic epoch
#

Can you elaborate?

thick mantle
#

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:

tropic epoch
#

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

thick mantle
#

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?

tropic epoch
#

Yup, it is triggered whenever a Checkout Session is completed.

thick mantle
#

Can I use the event id somehow to get the quantity? "evt_3NAeZ7GNjb0e7sHd1vsgSR84",

#

Or payment_intent": "pi_3NAeZ7GNjb0e7sHd1Kj2U8MA"

tropic epoch
#

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.

thick mantle
#

Is this: pi_1JGFa64XsdaddaBSbwSJtEu2 a checkout session id?

tropic epoch
#

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.

thick mantle
tropic epoch
thick mantle
#

How can I filter this in the api call?

tropic epoch
#

Pass the ID of the Payment Intent as a string to the payment_intent parameter.

thick mantle
#

Works like a charm! Thank you

tropic epoch
#

Any time!

thorny minnowBOT