New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Full access to response error object #206
Comments
@arekkubaczkowski looking at your MR, what I meant by the ticket was that the API error response looks like And we would like to access the paymentMethod field form the error because Stripe Radar failures dont give us info like "this failed because the funding type was prepaid, and we want to be able to tell the user that |
@agentscamp5 the SDKs do not return that level of information, but in the case of an error you can use Code: const { error, paymentIntent } = await confirmPayment(clientSecret, {
type: 'Card',
billingDetails,
});
if (error) {
console.log(JSON.stringify(error, null, 2));
const { paymentIntent } = await retrievePaymentIntent(clientSecret);
console.log(JSON.stringify(paymentIntent, null, 2));
Alert.alert(`Error code: ${error.code}`, error.message);
console.log('Payment confirmation error', error.message);
} else if (paymentIntent) {
Alert.alert(
'Success',
`The payment was confirmed successfully! currency: ${paymentIntent.currency}`
);
console.log('Success from promise', paymentIntent);
} Result: // error
{
"stripeErrorCode": "card_declined",
"message": "Your card was declined.",
"declineCode": "generic_decline",
"type": null,
"localizedMessage": "Your card was declined.",
"code": "Failed"
}
// paymentIntent.lastPaymentError
{
"type": "Card",
"message": "Your card was declined.",
"code": "card_declined",
"paymentMethod": {
"livemode": false,
"Card": {
"last4": "0002",
"expMonth": 12,
"funding": "credit",
"country": "US",
"expYear": 2022,
"brand": "Visa"
},
"Sofort": {
"country": null
},
"Upi": {
"vpa": null
},
"BacsDebit": {
"sortCode": null,
"last4": null,
"fingerprint": null
},
"SepaDebit": {
"fingerprint": null,
"last4": null,
"country": null,
"bankCode": null
},
"billingDetails": {
"name": null,
"address": {
"state": null,
"country": "US",
"line2": "Texas",
"line1": "1459 Circle Drive",
"postalCode": "77063",
"city": "Houston"
},
"phone": "+48888000888",
"email": "email@stripe.com"
},
"Ideal": {
"bankIdentifierCode": null,
"bankName": null
},
"id": "pm_1IvisVG7gfqYEkPO3vcbJZi4",
"type": "Card",
"AuBecsDebit": {
"last4": null,
"fingerprint": null,
"bsbNumber": null
},
"Fpx": {
"bank": null,
"accountHolderType": null
},
"customerId": null
}
} |
@thorsten-stripe THANKS!!!! |
@thorsten-stripe would that work for setupIntents as well? We would similarly want to retrieve a setupIntent that failed |
|
Our company uses Stripe's Radar for Fraud Teams to block certain types of cards from being used for things like setupIntents and paymentIntents (e.g. we are only letting debit cards be used right now, would reject a credit card). Right now in this package if we get an error, we are only provided the localizedDescription of the error object, but I can see from Stripe's API logs that the error object contains way more information. The error message for a card failing by Radar is very generic "Your card was declined", and if we had access to the full error object we could look into it and give more detailed messaging like "We do not accept credit cards".
A feature to have access to the complete response/error object that is returned from the Stripe API for unsuccessful requests would be very helpful.
The text was updated successfully, but these errors were encountered: