#rob_paymentintent-latestcharge
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/1275951717195714651
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
but when I try to retrieve it, in my firebase cloud function using the stripe api, it does not contain the charges array.
yes that's expected because thechargesarray was removed almost 2 years ago in the API when we shipped the API version https://docs.stripe.com/upgrades#2022-11-15
So if you are using a newer API version (likely because you have a recent SDK) then you don't get charges. You do get latest_charge: 'ch_123' instead which is the id of the Charge.
What you want is either retrieve that Charge directly in the API https://docs.stripe.com/api/charges/retrieve
Or instead use our Expand feature (see https://stripe.com/docs/expand and https://www.youtube.com/watch?v=m8Vj_CEWyQc) which lets you fetch the PaymentIntent and expand the whole Charge all in one request
So you want to change const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId); to const paymentIntent = await stripe.paymentIntents.retrieve(paymentIntentId, {expand: ['latest_charge']); const receiptUrl = paymentIntent.latest_charge.receipt_url
rob_paymentintent-latestcharge
awesome! Thanks again @zenith monolith ! I'll give that a try!
@zenith monolith Is the api version I am using correct/advised?
I mean it's up to you to decide which API version to use. It's usually tied to when you integrated Stripe. It's not always easy to "stay caught up" on newer API versions and make integration changes you might not need.
Yeah ok, but the one I am using is still within support etc (secure and safe)? Thanks again Koopajah! That worked a treat!
Can I buy you a coffee on here!?
In the request you shared, you're using stripe-node v12.1.1 which was released in April 2023 so not too old. But you're definitely multiple major versions behind as the latest version is 16.8.0.
Overall you're fine. If you have time at some point try upgrading to the latest SDK and then having your WebhookEndpoints use the latest API version. We have https://docs.stripe.com/webhooks/versioning that covers this
But there's no immediate pressure.
And no need to buy me a coffee! I work for Stripe and this is my job to help devs here ๐
Brilliant! Thanks again mate, I really do appreciate your time and expertise! I'll read through that document and migrate to latest version! Cheers! Have a great evening!