Fix Fontis eWay Magento Extension for Diners Card For Validation

Fontis Magento Extension for payment gateway “eWay” does not validate Diners Card numbers, and does not let customers complete a transaction. This often results in an abandoned sale.

To fix form validation in Magento you have to fix the javascript and php versions of the validation.

1. Replace the following javascript in “app/design/frontend/<your package>/<your theme>/template/fontis/ewayau/form.pthml” with the correct regular expressions like this:

<script type="text/javascript">
Validation.creditCartTypes.set('JCB', [new RegExp('^(35[0-9]{14}|(2131|1800)[0-9]{11})$'), new RegExp('^([0-9]{3})?$'), true]);
Validation.creditCartTypes.set('DICL', [new RegExp('^3(?:0[0-5]|[68][0-9])[0-9]{11}$'), new RegExp('^[0-9]{3}$'), true]);
</script>

Then copy “app/code/core/Mage/Payment/Model/Method/Cc.php” to “app/local/Mage/Payment/Model/Method/Cc.php” and add a new regular expression item to the array inside the “function validate()”:

$ccTypeRegExpList = array(
...
  'DICL' => '/^3(?:0[0-5]|[68][0-9])[0-9]{11}$/'   // DINER CLUB
...
);

And add an item to the array inside function getVerificationRegEx():

$verificationExpList = array(
...
  'DICL' => '/^[0-9]{3}$/'  // DINER CLUB
...
);

References: