Search code examples
localizationinternationalizationtranslationstripe-paymentsstripe.net

Non-English texts in Stripe possible?


Successfully integrating Stripe into my online shop, I completely failed to get information on whether/how to configure Stripe to return error messages in German instead of English.

So my question is:

Is there a way to have localized error messages when using the client-side API "https://js.stripe.com/v2"?

Update 2014-05-03

I've asked the same question on Twitter and one of their staff (I guess) told me that this is currently not possible and on their TODO list.


Solution

  • For further reference:

    While you can't use human messages on stripe errors to be displayed directly on localized pages, you can take advantage of response.error.code to provide your own translations.

        var errorMessages = {
          incorrect_number: "The card number is incorrect.",
          invalid_number: "The card number is not a valid credit card number.",
          invalid_expiry_month: "The card's expiration month is invalid.",
          invalid_expiry_year: "The card's expiration year is invalid.",
          invalid_cvc: "The card's security code is invalid.",
          expired_card: "The card has expired.",
          incorrect_cvc: "The card's security code is incorrect.",
          incorrect_zip: "The card's zip code failed validation.",
          card_declined: "The card was declined.",
          missing: "There is no card on a customer that is being charged.",
          processing_error: "An error occurred while processing the card.",
          rate_limit:  "An error occurred due to requests hitting the API too quickly. Please let us know if you're consistently running into this error."
        };
    
    
        function stripeHandler( status, response ){
          if ( response.error && response.error.type == 'card_error' ){
            $( '.errors' ).text( errorMessages[ response.error.code ] );
          }
    
          else {
            // do other stuff (and handle api/request errors)
          }
        }
    

    The list of codes is documented here (currently, right column, in the "codes" section).