20

Pomyślnie integrując Stripe z moim sklepem internetowym, całkowicie nie udało mi się uzyskać informacji, czy/jak skonfigurować program Stripe, aby zwracał komunikaty o błędach w języku niemieckim zamiast angielskim.Czy możliwe są teksty w języku innym niż angielski w paski?

Więc moje pytanie brzmi:

Czy istnieje sposób, aby mieć zlokalizowane komunikaty o błędach podczas korzystania z API po stronie klienta „https://js.stripe.com/v2”?

Aktualizacja 2014-05-03

Mam to samo pytanie na Twitterze i jeden z ich pracowników (chyba) told me that this is currently not possible i na ich liście TODO.

Odpowiedz

53

Dla dalszego odniesienia:

Chociaż nie można wykorzystywać ludzkich komunikatów o błędach paskiem być wyświetlane bezpośrednio na lokalnych stronach można wykorzystać response.error.code dostarczyć własne tłumaczenia.

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

Wykaz kodów is documented here (obecnie prawej kolumnie w sekcji „Kody”).

+0

Wielkie dzięki! Zaznaczę to jako odpowiedź :-) –

+2

Działa idealnie –

+1

Świetna odpowiedź! :) – facundofarias

Powiązane problemy