Magento 1.4.x checkout page not working – validation error
By Web Hosting Guru on Dec 08, 2010 with Comments 0
The latest 1.4.x series of Magento has some small changes/enhancements which are not exactly backward compatible.
This is especially true with themes.
As payment module developers, we get a lot of people coming back saying that after upgrade or fresh installation of the latest version, the payment step on the one page checkout doesn’t work.
If, you have a custom theme installed and, after upgrade, you find that your checkout is not working – that is after entering your credit card information and click ‘Next’ nothing happens – follow these steps:
1. Ensure that this issue is only for CC payments.
Disable all credit card payment methods and enable some other method like PayPal or COD. If, they too do not work, then, you have some other installation issue. Try reinstalling.
2. Switch to the default theme and it should work.
Disable your custom module and enable the default Magento module. If, credit card payment method works you can confirm that the issue is with your theme.
3. Fix your theme.
The reason that checkout for credit card payment methods do not work is because Magento the lib/ccard.js javascript file to be included, which does the credit card validations and has the click action for the ‘Next’ button.
To fix this you need to edit only one file – your custom theme’s layout/page.xml file.
Open page.xml file and add this line in these sections,
(1) Section:
after this line:
<block type=”page/html” name=”root” output=”toHtml” template=”page/2columns-left.phtml”>
Place this
<action method=”addJs”><script>lib/ccard.js</script></action>
So it will look like this
<block type=”page/html_head” name=”head” as=”head”>
<action method=”addJs”><script>prototype/prototype.js</script></action>
<action method=”addJs” ifconfig=”dev/js/deprecation”><script>prototype/deprecation.js</script></action>
<action method=”addJs”><script>lib/ccard.js</script></action>
(2) Section:
after this line:
<block type=”page/html” name=”root” output=”toHtml” template=”page/print.phtml”>
Place this
<action method=”addJs”><script>lib/ccard.js</script></action>
So it will look like this
<block type=”page/html” name=”root” output=”toHtml” template=”page/print.phtml”>
<block type=”page/html_head” name=”head” as=”head”>
<action method=”addJs”><script>prototype/prototype.js</script></action>
<action method=”addJs”><script>mage/translate.js</script></action>
<action method=”addJs”><script>lib/ccard.js</script></action>
I was experiencing the same issue: Nothing happens when you enter the credit card information and hit continue. After investigating with Firebug, it seemed that the method verifyCreditCard was not defined in validation.js.
You can fix this by pasting the following javascript code into validation.js:
// Credit Card Validation Javascript
// copyright 12th May 2003, by Stephen Chapman, Felgall Pty Ltd
// You have permission to copy and use this javascript provided that
// the content of the script is not changed in any way.
function validateCreditCard(s) {
// remove non-numerics
var v = "0123456789";
var w = "";
for (i=0; i < s.length; i++) {
x = s.charAt(i);
if (v.indexOf(x,0) != -1)
w += x;
}
// validate number
j = w.length / 2;
k = Math.floor(j);
m = Math.ceil(j) - k;
c = 0;
for (i=0; i 9 ? Math.floor(a/10 + a%10) : a;
}
for (i=0; i
Clear the cache and you should be able to checkout with the CC payment method.
About the Author:
