I need to know the promo code applied by the buyer during the checkout. The webhook event "checkout.session.completed" and the retrieve checkout session by id API don't have this detail, they only have a discount applied.
How can I get the applied promo code once the payment is done?
The checkout.session.completed
event contains a Checkout Session object but without line_items
expanded. What you'll need to do is make a separate call to retrieve the CheckoutSession and expand line_items.data.discounts
to get details about the coupon used: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-line_items-data-discounts