Hey there,
I’ve found a solution : modify templates/payment.php.
Find the line with the condition ‘if (response.error)’ then add some custom error messages :
var errorMessages = {
incorrect_number: "<?php _e( 'The card number is incorrect.', 'striper' ); ?>",
invalid_number: "<?php _e( 'The card number is not a valid credit card number.', 'striper' ); ?>",
invalid_expiry_month: "<?php _e( "The card's expiration month is invalid.", "striper" ); ?>",
invalid_expiry_year: "<?php _e( "The card's expiration year is invalid.", "striper" ); ?>",
invalid_cvc: "<?php _e( "The card's security code is invalid.", "striper" ); ?>",
expired_card: "<?php _e( "The card has expired.", "striper" ); ?>",
incorrect_cvc: "<?php _e( "The card's security code is incorrect.", "striper" ); ?>",
incorrect_zip: "The card's zip code failed validation.",
card_declined: "<?php _e( "The card was declined.", "striper" ); ?>",
missing: "There is no card on a customer that is being charged.",
processing_error: "<?php _e( "An error occurred while processing the card", "striper" ); ?>.",
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."
};
You will notice I use the _e() function to register variables in WPML so they are translatable after this with string translations.
Then replace this line :
$form.find('.payment-errors').text(response.error.message);
With:
$form.find('.payment-errors').text(errorMessages[response.error.code] );
That’s all ??
Cheers !