#teatea
1 messages · Page 1 of 1 (latest)
hi! if you retrieve the Session object it has a payment_intent field : https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-payment_intent and that can be passed to the refunds API.
Hi that only works for a single purchase checkout session
When I checkout with multiple items its set to null
hmm, that shouldn't be the case. Do you mean it's a type:subscription CheckoutSession?
do you have an example cs_test_xxx I can look at?
Yes, sorry subscription
cs_test_a1Z7wOw5TEwqOGsJgG76t9Gfjk8ZsQTonnoSnqnr7gvzLVjth39rg3Zx7e
cool, so it's a subscription. What do you want to refund exactly, that first initial immediate payment Checkout processed?
Yes, there are many use cases. It could be a partial refund/full refund
User can checkout with subscriptions & non subscriptions or either. how do i build a refund logic around this?
well starting with the CheckoutSession ID, you retrieve that and can access the Subscription. https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-subscription
From there you can do things like cancel that subscription with the Cancel Subscription API, or list all Invoices for that Subscription(https://stripe.com/docs/api/invoices/list#list_invoices-subscription), and each Invoice has a payment_intent field, which can be refunded. Depends what you're trying to do overall, it's flexible.
That's plenty for now thank you!
How do I refund non-subscription items from checkout session object that includes subscription items?
answering here
well, those items are part of the Invoice that got created
i.e. when you use Checkout this way, you now have a Subscription created, where the first Invoice for the subscription has charged for the first month of the recurring plan, plus whatever other items you passed to the line_items of the CheckoutSession. So you can refund that Invoice in full or in part.