#satyashetty

1 messages ยท Page 1 of 1 (latest)

warped runeBOT
#

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.

quick coyote
#

probably you're using different API versions.

graceful oar
#

ok so what is the way to get this , i have to switch to a older api version?

quick coyote
#

depends what you want really

graceful oar
#

"failure_code": "authentication_required",
"failure_message": "Your card was declined. This transaction requires authentication.",

quick coyote
#

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

graceful oar
#

this is wha i am looking for

#

i need 2 things actually: 1) payment_intent.charges.data[0].failure_code 2) payment_intent.status

quick coyote
graceful oar
#

ok so how do i get both these 1) payment_intent.charges.data[0].failure_code 2) payment_intent.status in node?

quick coyote
#
  1. I answered above
#
  1. let status = invoice.payment_intent.status
#

I think it's very straightforward but let me know if there's something I can clarify

graceful oar
#

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?

quick coyote
#

it expands both

graceful oar
#

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

quick coyote
#

yeah I know

#

I said to use latest_charge, not charges.data[0]

graceful oar
#

tried that too

#

same result

quick coyote
#

then you're doing something wrong

#

what does your exact code look like? What is the exact invoice ID?

graceful oar
quick coyote
#

expand: ['payment_intent.charges'] is not right

graceful oar
#

it has 'payment_intent.charges' , but changing it also gives same result

quick coyote
#

it's expand: ['payment_intent.latest_charge'] as I mentioned in a previous post

graceful oar
#

ok will give it a try again

quick coyote
#

also not all invoices have charges

graceful oar
#

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

quick coyote
#

great!

graceful oar
#

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

quick coyote
graceful oar
#

2022-11-15 - is the version of API i am using i guess

quick coyote
graceful oar
#

ok

#

thanks got it

#

๐Ÿ‘