#ambi_best-practices
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/1371479257083281408
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
basically I just want to update a row in my database using the invoiceId
Hi, can you share the event id where you expect to see the invoice id?
evt_3RMxNm2L54HYtpsW1xwkEtFT
here I can see the invoice
which is a charge.refunded event. however the node js library does not have it as a field
public async handleChargeRefunded(event: Stripe.ChargeRefundedEvent): Promise<boolean> {
const { invoice } = event.data.object
await this.prisma.invoice.update({
where: { invoiceId: invoice },
data: { amount: 0 },
})
return true
}
this is what I expected to write. however I understand the invoice is not availible on charge or refund objects. what is the next best approach
That is expected due to the latest version: https://docs.stripe.com/changelog/basil/2025-03-31/add-support-for-multiple-partial-payments-on-invoices to support flexible invoices.
To work around it...
You can use the pi_xxx ID from the payment_intent field with this API: https://docs.stripe.com/api/payment_intents/retrieve
And there you can expand: ['latest_charge'] to attain the invoice id, https://docs.stripe.com/api/expanding_objects
great. exactly what I was looking for
thanks alot
๐ค
one more API call but not so bad ๐
Sure
ah but wait, lastest_charge gives me the Charge object right? which does not have invoiceId on it
We get these questions often from different angles and I moved too fast/ copied the wrong thing
You can use the Invoice Payment endpoint and pass the payment intent there
Can you try this please?