Cleanest & fastest way to change payment gateway error messages for OneStepCheckout

Submitted by deeperdata - 3 years ago

I recently had to address confusing and verbose error messages being shown from Authorize.net in a client's OneStepCheckout page. I had read about several alternative methods to supplement 1 or 2 of the error messages but I was concerned about the usual things: Will this be compatible with an upgrade? Will this has any adverse effects on the functionality of the cart? Will this approach allow the client to easily maintain these messages? etc. Because of that, I decided to proceed by using jQuery to target the rendered error messages in the browsers and replace them completely. If you wanted to get created, you could even put the following snippet in a static block which would allow a client or fellow developer to easily locate and change these message text should they have to. I'll plan on posting a similar trick for OnePageCheckout as well.

<!-- Filepath:  app / design / frontend / yourpackage / yourtheme / template / onestepcheckout / -->

<script type="text/javascript">
jQuery( document ).ready(function() {
    // e.g. duplicate transaction detected...
jQuery("div.onestepcheckout-error:contains('duplicate')").html("There was a problem verifying your information. Please wait 30 seconds and try again.");
    // e.g. AVS mismatch...
jQuery("div.onestepcheckout-error:contains('AVS')").html("The transaction has been declined because of an address mismatch. The Zipcode provided does not match billing address of the credit card.");
    // Transaction has been declined...
jQuery("div.onestepcheckout-error:contains('has been declined')").html("Your credit card has been declined. Please verify your information.");
    // incorrect CVV code...
jQuery("div.onestepcheckout-error:contains('CVV')").html("Your 3 or 4 digit security code seems to be incorrect. Please verify your information.");

});
</script>
affiliate_link
Learn PHP
comments powered by Disqus
Proudly hosted on Digital Ocean