#satyashetty
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- satyashetty, 4 hours ago, 14 messages
- satyashetty, 23 hours ago, 25 messages
- satyashetty, 1 day ago, 6 messages
- satyashetty, 1 day ago, 18 messages
- satyashetty, 1 day ago, 5 messages
- satyashetty, 4 days ago, 21 messages
probably you're using different API versions.
payment_intent.charges was removed/not included by default in newer versions. https://docs.stripe.com/upgrades#2022-11-15
ok so what is the way to get this , i have to switch to a older api version?
depends what you want really
https://api.stripe.com/v1/invoices/in_1OmAKsSGmP5mAGB9TZQWNifh Vs const invoice = await stripe.invoices.retrieve(invoiceId, { expand: ['payment_intent'] }); --> will it hit a different API version?
"failure_code": "authentication_required",
"failure_message": "Your card was declined. This transaction requires authentication.",
to me the correct way is await stripe.invoices.retrieve(invoiceId, { expand: ['payment_intent.latest_charge'] }) and then you can do let code = invoice.payment_intent.latest_charge.failure_code
this is wha i am looking for
i need 2 things actually: 1) payment_intent.charges.data[0].failure_code 2) payment_intent.status
the difference is in POSTMAN you probably don't pass a Stripe-Version header so it uses your account's default API version, while stripe-node does, and it uses a specific, recent API version
ok so how do i get both these 1) payment_intent.charges.data[0].failure_code 2) payment_intent.status in node?
- I answered above
let status = invoice.payment_intent.status
I think it's very straightforward but let me know if there's something I can clarify
await stripe.invoices.retrieve(invoiceId, { expand: ['payment_intent.latest_charge'] }) --> will this only expand the section .latest_charge OR it will expand 'payment_intent' as well?
it expands both
sounds good will give it a shot
still getting undefined when i try to access payment_intent.charges.data[0].failure_code, I console logged invoice and there is no payment_intent.charges path
then you're doing something wrong
what does your exact code look like? What is the exact invoice ID?
in_1OmAKsSGmP5mAGB9TZQWNifh
expand: ['payment_intent.charges'] is not right
it has 'payment_intent.charges' , but changing it also gives same result
it's expand: ['payment_intent.latest_charge'] as I mentioned in a previous post
here
ok will give it a try again
also not all invoices have charges
invoice.payment_intent.latest_charge.failure_code
this is what i missed
let me try again with this code
works now thank you so much
great!
so ['payment_intent.latest_charge'] --> this has to be used for the api version i am using?
what was i doing wrong - for future reference
yes;
2022-11-15 - is the version of API i am using i guess
you were using .charges which doesn't exist in newer API versions. You have to understand that when using stripe-node it is 'pinned' to certain API versions
https://github.com/stripe/stripe-node/wiki/Migration-guide-for-v12 this talks about how the pinning works