Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

No translation option for stripe errors #80

Open
sechix opened this issue Apr 9, 2018 · 0 comments
Open

No translation option for stripe errors #80

sechix opened this issue Apr 9, 2018 · 0 comments

Comments

@sechix
Copy link

sechix commented Apr 9, 2018

I am trying to translate stripe errors but I have to override the stripe code in order to achive it, beacuse insert the code below in the payment view doesn´t work.

Are there any option to do it in a right way?
var errorMessages = {
incorrect_number: "Número de tarjeta incorrecto",
invalid_number: "EL número de tarjeta no es un número de tarjeta válido",
invalid_expiry_month: "El mes de caducidad de la tarjeta no es válido",
invalid_expiry_year: "El año de caducidad de la tarjeta no es válido",
invalid_cvc: "El código de seguridad de la tarjeta no es válido",
expired_card: "La tarjeta ha caducado",
incorrect_cvc: "Código de seguridad de la tarjeta incorrecto",
incorrect_zip: "Falló la validación del código postal de la tarjeta",
card_declined: "La tarjeta fué rechazada",
missing: "El cliente al que se está cobrando no tiene tarjeta",
processing_error: "Ocurrió un error procesando la tarjeta",
rate_limit: "Ocurrió un error debido a consultar la API demasiado rápido. Por favor, avísanos si recibes este error continuamente"
}

if(response.error){
    $('#stripeError').html(errorMessages[response.error.code]);
    $('#stripeError').show();
} else {
    Spree.stripePaymentMethod.find('#card_number, #card_expiry, #card_code').prop("disabled" , true);
    Spree.stripePaymentMethod.find(".ccType").prop("disabled", false);
    Spree.stripePaymentMethod.find(".ccType").val(mapCC(response.card.type))
    token = response['id'];
    // insert the token into the form so it gets submitted to the server
    Spree.stripePaymentMethod.append("<input type='hidden' class='stripeToken' name='subscription[card_token]' value='" + token + "'/>");
    Spree.stripePaymentMethod.parents("form").get(0).submit();
}

}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant