#mentijm - credit-note
1 messages ยท Page 1 of 1 (latest)
Hi! With the API here's how you can create a credit note for an invoice: https://stripe.com/docs/api/credit_notes/create
Hey! Yeah I see that but I need to send line items
and they need to have quantity for normal line items and amount for proration it seems. Got that far but I dont understand this error message
Should refunds/cns include tax to be full?
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
@bronze skiff There's a proration_details hash on the Invoice Line Item object: https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-proration_details
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
That'll give you any details re: proration (it's a pretty new field, let me know if it's useful)
Ok, and how would one create a credit note on an original invoice containing proration?
Tried with sending the proration line to creditnote creation and just issuing the credit note based on the normal purchase line
screenshot without the proration
Hmm, what are you actually trying to achieve here?
when we refund a invoice/payment it triggers a charge.refunded but we wanna have a credit note for that one as well
so we doing refund: re_1234 (example refund id from charge.refunded webhook payload) instead of the amount in the picture above
Can you share the Invoice ID?
in_1KbiPSLLAsLlRiDemp3kEAXD
Maybe this makes the goal/purpose clearer for you
This was what we had earlier (before realising that it didn't work for refunds of invoices with proration items)
And the goal is to always have a credit note for each refund (but we still wanna let support into Stripe dashboard but it's very easy to find the refund button everywhere and go that route instead of issuing a credit note with a refund)
Taking a look
Thank you
Ok, here's the request ID I'm looking at: https://dashboard.stripe.com/test/logs/req_QkhjXYfnn4ZgcB
{
error: {
message: "The total amount of all credit notes associated with invoice line item il_1KbiPSLLAsLlRiDeS0WT6aXq cannot exceed the invoiced amount (including discounts and taxes) for the line item.",
type: "invalid_request_error"
}
}
Ok, that was one were I changed the -29988 to absolute number tho (to get it through the 1 or greater error message)
The issue is that that Invoice Item already has a proration/credit applied
Yes, I understand that, but how does one create a credit note for such a case then?
say I buy 1 license x 375usd
instantly add a license (which makes a new invoice of 375*2 total - the proration of 375 for the unused time)
Yes, but creating a Credit Note applies the adjustments to the applicable invoice. In the case of in_1KbiPSLLAsLlRiDemp3kEAXD, there's already prorations applied to account for those adjustments
Do you need a credit note purely for accounting purposes or something?
Yes that was our plan
So what does this mean basically?
We can't issue a credit note to an invoice that contains an proration item?
I think you can, I'm just not sure what parameters/values you need to pass in this instance. Checking
Ok thanks ๐
I guess I'm missing something but can't you just do this?
const creditNote = await stripe.creditNotes.create({
invoice:subscription.latest_invoice.id,
refund_amount: subscription.latest_invoice.amount_due,
lines: [{type:"custom_line_item", description:"Refund", unit_amount:subscription.latest_invoice.amount_due, quantity:1}]
});
it's not perfect really since it's just "hacking" a custom line item but I don't see how else we expect this to work โ each line has to be positive, and the amount from all the CreditNote lines has to add up to the total amount being refunded, so you can't really transpose the Invoice line items directly into it. This I suppose works, but admittedly I rarely use this API at all.
Hi again
Stripe::InvalidRequestError: Custom line items are not supported for invoices with automatic_tax.enabled = true.
It says this hmm
oh, that's annoying
yeah I don't know you can do this, sorry
my best effort is
lines = lines.data.filter(x => x.amount > 0).map(x => {return {type:"invoice_line_item", amount:x.amount, invoice_line_item:x.id}})
const creditNote = await stripe.creditNotes.create({
invoice:subscription.latest_invoice.id,
refund_amount: subscription.latest_invoice.amount_due,
lines: lines
});
i.e. create the lines for the credit note only using the positive items on the invoice, but then the lines won't add up to refund amount (because they don't include the negative proration) so you get
The credit note amount ($300.00) must be less than the invoice amount ($200.00).
I'll try seeing what the dashboard does is if I use that to issue a credit note for this invoice...
ah right, I see.
you are meant to credit the invoice line item but not use its amount, instead change it so that it's smaller and inclusive of the proration or so on, so that it adds up to less than the total amount. Which requires custom business logic(or manually typing a number as the dashboard does it). It's making more sense to me now.
well, any of the positive ones.
you have to credit the positive ones but only for amounts that ultimately add up to being less-than-equal-to the actual invoice total