This npm package contains translations for all stripe.com declined codes that the user can fix. Checkout the stripe readme @ https://stripe.com/docs/declines/codes and the wiki @ https://github.com/stripe/stripe-node/wiki/Error-Handling
Install the package with:
$ yarn add stripe-i18n-declined-codes
import Stripe from 'stripe'
import { EN_TRANSLATIONS } from 'stripe-i18n-declined-codes'
const stripe = new Stripe(STRIPE_SECRET_KEY)
stripe.charges.create({
amount: 995,
// ...
}).then(
function (result) {},
function (err) {
if(err.type === 'StripeCardError') {
return EN_TRANSLATIONS[err.code] || ' ... generic payment error occured'
}
// ...
}
)
This package supports the following languages as exports:
import { DE_TRANSLATIONS } from 'stripe-i18n-declined-codes'
import { EN_TRANSLATIONS } from 'stripe-i18n-declined-codes'
import { ES_TRANSLATIONS } from 'stripe-i18n-declined-codes'
import { FR_TRANSLATIONS } from 'stripe-i18n-declined-codes'
Run all tests:
$ yarn install
$ yarn test