When testing to confirm a payment with the next card (which should be declined after the authentication screen), the error NSLocalizedDescription is not translated in the correct language (I'm testing with a simulator in french).
4000 0084 0000 1629
STPPaymentHandler.shared().confirmPayment(paymentIntentParams, with: self, completion: { (status, paymentIntent, error) in
print(error)
})
The print return:
Optional(Error Domain=STPPaymentHandlerErrorDomain Code=8 "Your card was declined." UserInfo={com.stripe.lib:ErrorMessageKey=There was an error confirming the Intent. Inspect the `paymentIntent.lastPaymentError` or `setupIntent.lastSetupError` property., NSLocalizedDescription=Your card was declined.})
But when I test with the next card (which is always refused), the error message is correctly translated:
4000 0000 0000 0002
Optional(Error Domain=com.stripe.lib Code=70 "Votre carte a 茅t茅 refus茅e." UserInfo={com.stripe.lib:ErrorMessageKey=Your card was declined., com.stripe.lib:StripeErrorCodeKey=card_declined, com.stripe.lib:StripeErrorTypeKey=card_error, com.stripe.lib:CardErrorCodeKey=com.stripe.lib:CardDeclined, NSLocalizedDescription=Votre carte a 茅t茅 refus茅e.})
Any ideas?
12.4
16.0.7
Hey @aurelhubert, this message is coming from the Stripe API. We're working on a fix that would allow the API to send the correct localized message to your app.
In the meantime, you should be able to work around this by checking the paymentIntent.lastPaymentError.code and returning your own message. The value in this case would be card_declined, other values are on our site. I realize this is kind of unpleasant, but we hope to have a better solution for you soon.
@davidme-stripe Thanks for the quick reply! I was planning to use this code to manage the errors as a first step, I will follow the next releases of the SDK.
Hello, have you any information about the release date of this issue ?
Today, I hope.
It's out! Stripe 18.0.0 will send the user's display language to the server, and PaymentIntent errors should now be localized in all our supported languages.
hi @davidme-stripe , there is no decline_code in error response.
Can you tell me how to get the decline_code in declined case?
Thanks
Error Domain=com.stripe.lib Code=70 "Your card was declined" UserInfo={com.stripe.lib:ErrorMessageKey=Your card was declined., com.stripe.lib:StripeErrorCodeKey=card_declined, com.stripe.lib:StripeErrorTypeKey=card_error, com.stripe.lib:CardErrorCodeKey=com.stripe.lib:CardDeclined, NSLocalizedDescription=Your card was declined})
Most helpful comment
Hey @aurelhubert, this message is coming from the Stripe API. We're working on a fix that would allow the API to send the correct localized message to your app.
In the meantime, you should be able to work around this by checking the
paymentIntent.lastPaymentError.codeand returning your own message. The value in this case would becard_declined, other values are on our site. I realize this is kind of unpleasant, but we hope to have a better solution for you soon.