#ekko123
1 messages ยท Page 1 of 1 (latest)
Discount doesn't support retrieval API
Can you share what you would like to achieve?
We handle "checkout.session.completed" webhook in our system and update order data, after that we send out our custom receipt. For the receipt we would like to add name of the used discount code. We have tried achieving this by handling "customer.discount.created" webhook and updating that data to the order object.
But we have potential issue where discount webhook comes after session complete webhook.
One possible way is to use Checkout Session Retrieval API [0] and expand [1] total_details.breakdown [2]. You will get discounts information in total_details.breakdown.discounts
[0] https://stripe.com/docs/api/checkout/sessions/retrieve
[1] https://stripe.com/docs/api/expanding_objects
[2] https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-total_details-breakdown
You can do the retrieval call after receiving the checkout.session.completed event
This fixes our problem!! Sorry to bother you with something that is clearly stated in documentation, don't know how I missed the expand flag... ๐
Thank you so much!! ๐
No problem! The expand flag on the discounts is not that obvious. We are happy to help ๐
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!