#alexanderg-PaymentIntent-Decline

1 messages ยท Page 1 of 1 (latest)

languid cove
#

Hello

#

Is there a message related to that exception?

#

Do you have the request id (req_123) or PaymentIntent id (pi_123) for a time when this has happened?

languid cove
#

Thank you

lilac onyx
#

I am looking to get pi_3JafO5I7FT03hK3l1El5ZjQx while making API call PaymentIntent.create

#

(the fact that it failed is correct - just need to get the id, ideally in the same call)

languid cove
lilac onyx
#

We are catching generic Exception but if you have details please let me know which exception I should catch to cover card auth failure scenarios and how to extract id from there.

languid cove
#

That doc says CardException

  // Use Stripe's library to make requests...
} catch (CardException e) {
  // Since it's a decline, CardException will be caught
  System.out.println("Status is: " + e.getCode());
  System.out.println("Message is: " + e.getMessage());
}```
lilac onyx
#

CardException does not have the id of the created PaymentIntent

#

Once the call is over how could I link the failure to the specific intent created in Stripe

lethal mortar
#

@lilac onyx oh sorry I joined the thread and missed this, give me a sec

#

there should be a e.payment_intent property on that error, right? which should contain the full PaymentIntent

log out the full e object to see

lilac onyx
#

I am unable to see this property in Stripe API CardException or its superclass

lethal mortar
#

this is Java right?

lilac onyx
#

Correct

lethal mortar
#

yeah I'm not sure off hand, let me check

like the API returns the error, Java deserializes it into an object so it just might be somewhere else on that object etc

lilac onyx
#

Thank you! ๐Ÿ‘

wraith sleet
#

@lilac onyx just to confirm you want to get the PaymentIntent id after the error you get on capture?

#

If so you want something like this: } catch (InvalidRequestException e) { System.out.println("Error message is : " + e.getMessage()); String paymentIntentId = e.getStripeError().getPaymentIntent().getId(); System.out.println(paymentIntentId); }

lilac onyx
#

Correct

#

The above would be the code to do this?

wraith sleet
#

yes

lilac onyx
#

Thank you ๐Ÿ‘