#lostoros - charge and product
1 messages · Page 1 of 1 (latest)
The payments are generated from the payment links created using the dashboard
The end goal is to have a table for each product and populate it with the customers that bought the product and the quantity
Got it - so yea, payment links make use of Checkout sessions that are created for you
and where are you trying to access this data? you said via the API?
Yes the API
Ok so to get those details of the item purchased you want to inspect the line_items of the Checkout sessions:
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items
Note they are not included in the result by default an need to be included via expansion:
https://stripe.com/docs/api/expanding_objects
use eg expand[]=line_items when retrieving one session or expand[]=data.line_items if listing many sessions
If you're looking at a specific payment intent id, you can find list sessions filtered for a payment intent id:
https://stripe.com/docs/api/checkout/sessions/list#list_checkout_sessions-payment_intent
Yes this is very helpful thank you!
The solution I have in mind is to create a webhook for a successful checkout session >> request the session from with the expanded line_item >> the session contains the customer id which I can use to get the customer info.
- based on your knowledge of the system does this sound possible?
- Does the webhook contain the event id? for example with the checkout session : "cs_...."
Yes and yes 🙂
THat's a good approach for handling this and yes the checkout.session.completed event will have the checkout session id in the payload -- the data object is a checkout session object
Perfect, thank you so much! I have been struggling with this since last night
happy to help, hope it cleared some stuff up for you!