#rust_api
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1446293359512522885
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
in_1SOVzbJW1HYWVXZV4q8PoZfn is an instnace of a credit memo being voided
I know i can do this through the credit note api for sure but I want to avoid sending requests so i dont hit the rate limit of 100/second
hi there, give me a moment to catch up
You can consider setting up a webhook to listen for the credit_note.created event [0] and then inspect the event body to retrieve the invoice id the credit note was applied to.
[0] https://docs.stripe.com/api/events/types#event_types-credit_note.created
is there a way i can avoid that, could i somehow calculate if a credit note was applied by computing something once the invoice webhook event comes in ?
Hmm...I can check that but I would need a more recent invoice. Do you have an invoice created in the last 30 days with a credit note applied?
I dont unfortunately, this is the only edge case i found when backfill one of my customers
all good. I was looking at in_1SEeXzJW1HYWVXZVKYCLjmwj initially but I noticed you shared another invoice ID.
in_1SOVzbJW1HYWVXZV4q8PoZfn is pretty new so I can check its event logs, give me a moment
Are you already listening to invoice webhooks like invoice.updated?
yes i am, currently listening to paid, payment failed, created, updated, finalized,
okay, in that case, when a credit note is applied to an invoice, Strpe emits two events โ credit_note.created and invoice.updated
Since you are already listening to invoice.updated, you can look at pre_payment_credit_notes_amount parameter in this event after you apply a credit note to an invoice.
You can view this event in your Dashboard as an example: evt_1SVcvaJW1HYWVXZV1oixTxUV
pre_payment_credit_notes_amount should be a non-zero value if the credit note is applied on the invoice (i.e. not voided)
evt_1SVcvaJW1HYWVXZV1oixTxUV is from in_1SOVzbJW1HYWVXZV4q8PoZfn.
Also, after a credit note is applied to an invoice, any changes to the credit note will also emit invoice.updated event for the invoice. But I would still recommend listening to credit note events for easier tracking of the credit note status
got it, so it sounds like theres no way to infer the credit note application from just the invoice object
I'll give this a try tomorrow
btw, for starting_balance and ending_balance within the invoice object, is that based off of credit notes as well ?
or do i have to track something else
starting_balance is unrelated to credit notes: https://docs.stripe.com/api/invoices/object#invoice_object-starting_balance
The only way to infer credit note application from just the invoice object is using pre_payment_credit_notes_amount [0] or post_payment_credit_notes_amount [1] parameter on the invoice object. But the invoice object does not reflect the credit note status if that's what you're looking for.
[0] https://docs.stripe.com/api/invoices/object#invoice_object-pre_payment_credit_notes_amount
[1] https://docs.stripe.com/api/invoices/object#invoice_object-post_payment_credit_notes_amount
got it ok
as for balance, it looks like i need to reference https://docs.stripe.com/api/billing/credit-balance-transaction/object ?