#teatea

1 messages · Page 1 of 1 (latest)

serene waspBOT
covert shard
exotic mica
#

Hi that only works for a single purchase checkout session

#

When I checkout with multiple items its set to null

covert shard
#

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?

exotic mica
#

Yes, sorry subscription

#

cs_test_a1Z7wOw5TEwqOGsJgG76t9Gfjk8ZsQTonnoSnqnr7gvzLVjth39rg3Zx7e

covert shard
#

cool, so it's a subscription. What do you want to refund exactly, that first initial immediate payment Checkout processed?

exotic mica
#

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?

covert shard
#

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.

exotic mica
#

That's plenty for now thank you!

covert shard
#

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.