#pro-pooja
1 messages · Page 1 of 1 (latest)
Hi there!
Note that you'll have to use expand: ["total_details.breakdown"] in order to view that field
If you are not familiar with expand, you can learn more about it here: https://stripe.com/docs/expand
let me try, thanks
How to get an applied promo code name?
you would loop through the discounts in the breakdown property, and each one has a promo code (https://stripe.com/docs/api/discounts/object#discount_object-promotion_code) and then you can retrieve that object and investigate it(https://stripe.com/docs/api/promotion_codes/object)
I am listening to checkout.session.completed event , Just to get promotion code, I've to call two APIs, First get checkout session and then prmotion code?
yep it can be several API calls to get this information
note you can pass expand=>["total_details.breakdown.discounts.discount"] to skip at least one call for retrieving the Discount
Thanks, let me try
Hey, I passed the parameter expand=>["total_details.breakdown.discounts.discount"] in get checkout session api, but still it's not returning applied promo code.
what does it return instead?
yep, which is normal
so now you can make a call to https://stripe.com/docs/api/promotion_codes/retrieve, passing that ID, to get the other information about it
Does that mean I've to make 2 API calls?
yep it can be several API calls to get this information
I am using stripe-hosted checkout to complete the payment flow. Also, using couple of stripe webhooks. Is there any workaround to get the payment details with applied promo code with minimum API calls?
what we're talking about in this thread is the way with minimum API calls, we're already answering your question
you have to make some extra API calls when handling the checkout.session.completed event to get every single detail about the payment especially when it has some extra complexity like applied discounts; it's just how this is designed. It's no big deal to make some API calls.
Okay, got it.