#jayy_invoice-payments
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/1387186501007184024
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
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..
}
I assume you upgraded to the latest major version which came with dozens of fundamental breaking API changes
You should read https://docs.stripe.com/changelog/basil/2025-03-31/add-support-for-multiple-partial-payments-on-invoices which explains this specific change
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?
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
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
so you can't do this in your webhook handler. You have to first call the Retrieve Invoice API and explicitly expand the payments property, see https://docs.stripe.com/expand#includable-properties
it's not included by default now when we receive a webhook event of invoice.payment_succeeded?
jayy_invoice-payments
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?
yes
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
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
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
ah yeah that is a common mistake when upgrading and not realizing you have to upgrade the WebhookEndpoint too
let's hope upgrading the endpoint doesnt cause chaos for us now ๐
Thanks Koopajah x
https://docs.stripe.com/webhooks/versioning is a good read for this
awesome!
this is great!
thanks again for the help guys โค๏ธ
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
๐ Stepping in for my teammate
Once a WebhookEndpoint is created, it's not possible to update its API version
even for local ones?
What do you mean by local ones exactly?
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_................
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
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?
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