WordPress.org

Forums

Striper - Stripe Integration for WooCommerce
[resolved] Translating error messages (4 posts)

  1. katalonian
    Member
    Posted 1 year ago #

    Hi there!
    First of all, thanks for a great plugin!

    I want to translate error messages for checkout. I found in stripe_gateway.php some text which i can translate, but seems to be error messages incoming straight from stripe's web site. Is there is a way to localize them? Thank a lot!

    https://wordpress.org/plugins/striper/

  2. Benetan
    Member
    Posted 10 months ago #

    Same for me. Is there a way to do it ?

    Thank you !

  3. mgiulio
    Member
    Plugin Author

    Posted 10 months ago #

    Hi,

    this feature is on the TODO list, maybe for the next release.

    Cheers,
    Giulio.

  4. Alchimix
    Member
    Posted 9 months ago #

    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 !

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Striper - Stripe Integration for WooCommerce
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic