#ambi_best-practices

1 messages ยท Page 1 of 1 (latest)

waxen viperBOT
#

๐Ÿ‘‹ 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.

glossy raft
#

basically I just want to update a row in my database using the invoiceId

exotic zinc
#

Hi, can you share the event id where you expect to see the invoice id?

glossy raft
#

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

exotic zinc
#

To work around it...

glossy raft
#

great. exactly what I was looking for

#

thanks alot

#

๐Ÿค

#

one more API call but not so bad ๐Ÿ˜„

exotic zinc
#

Sure

glossy raft
#

ah but wait, lastest_charge gives me the Charge object right? which does not have invoiceId on it

exotic zinc
#

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?

waxen viperBOT