#jayy_invoice-payments

1 messages ยท Page 1 of 1 (latest)

torn wrenBOT
#

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

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

quiet crystal
#

btw i'm using "stripe": "^18.2.1"

here is a formatted version of the code

@StripeWebhookHandler('invoice.payment_succeeded')
  public async stripeWebhookInvoicePaymentSucceeded(
    event: Stripe.Event,
  ): Promise<void> {
    const evtData = event.data.object as Stripe.Invoice;
      const paymentIntent = evtData.payments?.data.at(0)?.payment
        .payment_intent as Stripe.PaymentIntent; // the property doesnt exist here anymore.. i cannot access the payments property.. 
}
vast bluff
#

Ah wait the code looks like it's updated already? I'm... confused by your comment in the code const evtData = event.data.object as Stripe.Invoice; const paymentIntent = evtData.payments?.data.at(0)?.payment .payment_intent as Stripe.PaymentIntent; // the property doesnt exist here anymore.. i cannot access the payments property..
Are you saying the type disappeared or just that the property is null in the Event? Or something else?

quiet crystal
#

there's a discrepency between what i see in the log of event.data.object and what eslint and the Stripe.Invoice type is showing me. i'll attach a couple screenshots

#

this is what i have logged in my console.. no payment property to access

#

this is the invoices.d.ts in my node modules

#

the types are messed up for some reason, i'm sure it's a error from my side but i cant figure out what's wrong

vast bluff
#

Pictures aren't really helpful

#

But I think I can guess what you missed

#

the payments property on Invoice does exist but it is includable which means it is not returned by default. So it is absent/null if you try to access it on an Invoice object in an Event

quiet crystal
#

it's not included by default now when we receive a webhook event of invoice.payment_succeeded?

vast bluff
#

jayy_invoice-payments

quiet crystal
#

alright, i'll try to get the invoice again and include the payments

#

but just to be sure, the correct type for that specific event is Stripe.Invoice yes?

vast bluff
#

yes

quiet crystal
#

okay, i think it's some kind of a mess-up with node modules if i cant see the correct types then. as when i tried to access event.data.object.payment_intent, it says payment_intent does not exist on type Invoice

vast bluff
#

sorry wrong thread

#

Are you mixing things up again? You are now trying to access a different property payment_intent instead of payments

#

that was deprecated in the latest major when we introduced payments

quiet crystal
#

wait i think i know what the issue is now.. we upgraded stripe sdk in our code, but we're using Stripe API Version [2022-11-15] ....

#

because in the webhooks i am getting a payment_intent property (which is an ID of the payment intent) but i cannot see it in my types

vast bluff
#

ah yeah that is a common mistake when upgrading and not realizing you have to upgrade the WebhookEndpoint too

quiet crystal
#

let's hope upgrading the endpoint doesnt cause chaos for us now ๐Ÿ˜“

#

Thanks Koopajah x

vast bluff
quiet crystal
#

awesome!

torn wrenBOT
quiet crystal
#

one more question cz i think i'm lost.. where in the dashboard do i update the webhook endpoint version? i cant seem to find it in the workbench

upbeat hearth
#

๐Ÿ‘‹ Stepping in for my teammate

#

Once a WebhookEndpoint is created, it's not possible to update its API version

quiet crystal
#

even for local ones?

upbeat hearth
#

What do you mean by local ones exactly?

quiet crystal
#

when i run the stripe cli to forward events to my laptop for testing, the cli says:

> stripe listen --forward-to localhost:5001/v1/stripe/webhook
A newer version of the Stripe CLI is available, please update to: v1.27.0
> Ready! You are using Stripe API Version [2022-11-15]. Your webhook signing secret is whsec_................
upbeat hearth
#

Ah gotcha. No, this isn't currently possible with the CLI. There are other flags you can use to specify things like headers, which local endpoint to forward to, etc. but the CLI will always use your account's default API version

quiet crystal
#

then how would i be able to run local tests for when i create the new endpoint, is there a way to change the default api version for my account? make it the latest one?

upbeat hearth
#

You'll need to set up something like ngrok and create a WebhookEndpoint pinned to a specific version

#

It's possible to change the default API version on your account but I don't recommend doing this without understanding what other code (if any) is still using your account's default version. You can read more about that here: https://docs.stripe.com/upgrades