#Mahesh K

1 messages ยท Page 1 of 1 (latest)

acoustic tuskBOT
copper gale
#

๐Ÿ‘‹ How can we help?

upbeat thunder
#

when the invoice payment is failed because of some random issues. i am able to catch through webhooks, and the problem i am facing is ..how to find the reason of failure of invoice payment

copper gale
#

Can you share the invoice ID (in_xxx), so that I can have a check?

upbeat thunder
#

yes

#

in_1MyYDDQrHwH0FKGrghmBdiLI

#

i am able to find the reason from the dashboard

#

when i receive the webhook event how to find the reason of failure through the response

copper gale
upbeat thunder
#

wow, that's so helpful.

copper gale
#

An additional Invoice Retrieval request can be made after receiving the the invoice.payment_failed event

upbeat thunder
#

wait i will check

copper gale
#

๐Ÿ‘

upbeat thunder
#

const invoice_failed_reasons = await stripe.invoices.retrieve(failed_invoice.id, {
expand: ['payment_intent', 'payment_intent.last_payment_error.message'],
stripeAccount: accountID,
});

#

is it true?

copper gale
#

It should be something like this:

const invoice = await stripe.invoices.retrieve('in_xxx', 
  {
    expand: ['payment_intent',],
  }, {
    stripeAccount: 'acct_xxx',
  });
upbeat thunder
#

ok๐Ÿ˜Š

#

thank you!

copper gale
#

No problem! Happy to help ๐Ÿ˜„

upbeat thunder
#

yoooooh!

#

it works

#

Thank you river

#

last_payment_error: {
code: '',
decline_code: 'generic_decline',
message: "The customer's bank account has been closed.",
payment_method: [Object],
type: 'card_error'
},

copper gale
#

That's awesome! Great to hear that ๐Ÿ‘

upbeat thunder
#

hey river

#

last_payment_error: {
code: '',
decline_code: 'generic_decline',
message: "The customer's bank account has been closed.",
payment_method: [Object],
type: 'card_error'
},

copper gale
#

Yes, how can I help?

upbeat thunder
#

can i use the same expand method to expand payment_method

#

?

copper gale
#

Isn't the payment_method in the last_payment_error already an expanded object?

upbeat thunder
#

nope

#

its just showing [object]

#

in my console

copper gale
#

It's likely because you log the object instead of accessing it directly. Could you try to retrieve and log last_payment_error.payment_method directly instead?

#

Since it's in object type, this means that it's already expanded

#

Just that you need to retrieve it directly to get the details instead of logging high level object such as last_payment_error

upbeat thunder
#

ok river

#

gotcha