#JCrags

1 messages Β· Page 1 of 1 (latest)

forest ravineBOT
tawdry reef
magic kindle
#
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,
)
tawdry reef
#

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?

magic kindle
#

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?

tawdry reef
#

discount is the ID that represents a coupon or promo code being used

#

Yup, you should use coupon to apply any discount

magic kindle
#

ok, i will give that a try

tawdry reef
magic kindle
#

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 πŸ™‚

tawdry reef
#

Sure! Let me know if you have any follow up questions

magic kindle
#

It works xD

#

Thanks for your help πŸ™‚

tawdry reef
#

No problem! Happy to help πŸ˜„

magic kindle
#

Have a nice morning/day/evening πŸ™‚