#JCrags
1 messages Β· Page 1 of 1 (latest)
Can you share the request ID (req_xxx) where you applied the coupon? Hereβs how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
req_akYGY4lA2sJNZ1
I mean this part "does not exist on the invoice" is a bit weird to me. It's quite obvious it doesn't exist on the invoice, because it is created before the invoice is created (so that you can connect it to the invoice).
Code (not that it matters much though):
// Add discount to invoice params
var discounts []*stripe.InvoiceDiscountParams
for _, v := range s.TotalDetails.Breakdown.Discounts {
discounts = append(discounts, &stripe.InvoiceDiscountParams{
Discount: &v.Discount.ID,
})
}
iparams.Discounts = discounts
// Create the invoice
newIn, _ := stripeInvoice.New(iparams)
ipParams := &stripe.InvoicePayParams{
PaidOutOfBand: stripe.Bool(true),
}
in, _ = stripeInvoice.Pay(
newIn.ID,
ipParams,
)
A discount (di_xxx) refers to the actual application to the payment. In this case, di_1LkIGXFKn7uROhgCKGexqMHc is the actual application for the payment on the checkout session.
Could you share what your use case is?
I do not understand what you mean by the actual application to the payment, but are you saying I should/could use Coupon: &v.Discount.Coupon.ID instead?
discount is the ID that represents a coupon or promo code being used
Yup, you should use coupon to apply any discount
ok, i will give that a try
You should use discounts.coupon instead: https://stripe.com/docs/api/invoices/create#create_invoice-discounts-coupon
i did use that method on checkout creation though not sure why i now used Discount: xxx instead in the code.
I am giving it a try right now π
Sure! Let me know if you have any follow up questions
No problem! Happy to help π
Have a nice morning/day/evening π