Non-English texts in Stripe possible?

前端 未结 6 1590
迷失自我
迷失自我 2021-02-01 16:25

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 Eng

6条回答
  •  谎友^
    谎友^ (楼主)
    2021-02-01 16:41

    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).

提交回复
热议问题