#JCrags
1 messages · Page 1 of 1 (latest)
So you want to apply the coupon to the items in the Checkout Session, then apply that same discount again after the Checkout Session is complete?
The checkout doesn't create an invoice, so I have to do this myself. There is no discount on the items themselves, just a global coupon that is added on top of the subtotal of the order.
I thought it would make sense to apply that exact same coupon that was created before/on the checkout session. And use that on the invoice, but I guess it doesn't work like that. All I see is the total_details.amount_discount when the webhook checkout.session.completed is called.
Why not apply the coupon on the Checkout Session itself and build the invoice with the discounts already baked in?
I am applying the discount on the checkout iself. It's there. But how can I create the invoice with that same coupon that I created. I see that the invoice/create takes an discount.coupon but the issue is that the webhook of the checkout session doesn't return this. It only returns the discount amount that was on the checkout session.
I might have found it...
Is it this:
I believe that could work for your use-case