1.0.0 • Published 5 years ago

stripe-i18n-declined-codes v1.0.0

Weekly downloads
12
License
MIT
Repository
github
Last release
5 years ago

stripe-i18n-declined-codes

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

Installation

Install the package with:

$ yarn add stripe-i18n-declined-codes

Usage Example

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'
    }
    // ...
  }
)

Supported Languages

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'

Development

Run all tests:

$ yarn install
$ yarn test