Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at magento.stackexchange.com, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email community@magento.com.

Magento Forum

Credit Card Types Problems UK / Europe based credit cards magento doesnt accept? 
 
bolasevich
Sr. Member
 
Avatar
Total Posts:  235
Joined:  2008-03-04
Newington, CT USA
 

I’ve recently developed a few payment modules but now im testing on one that is for the UK and before it even gets to my payment module code it is telling me the credit card number for “UK Mastreo” is not correct”

Card type doesn’t match credit card number (under creditcard type field)
and
Credit card number doesn’t match credit card type (under creditcard field)

How can i change this to make it work? is there some validation file that i can adjust to allow for the UK credit cards? I am able to select “UK Mastreo” from the dropdown but it just gives me this error message. any help here would be great.

Thanks
Scott

 
Magento Community Magento Community
Magento Community
Magento Community
 
LindyKyaw
Sr. Member
 
Avatar
Total Posts:  138
Joined:  2008-01-02
Los Angeles
 

You need to overwrite the existing client site and server site validation.

To overwrite client site validation, you need to create a new block for your payment.

1) In you payment class, add

protected $_formBlockType 'mymodule/form';
2) create a block class
class Mage_MyModule_Block_Form extends Mage_Payment_Block_Form_Cc
{
  
protected function _construct()
    
{
        parent
::_construct();
        
$this->setTemplate('mymodule/form.phtml');
    
}
}
3) copy the payment/form/cc.phtml into mymodule/cc.phtml
4) change the class name “validate-cc-type-select” to sth like “validate-mymodule-cc-type-select” and add your validation in the javascript like following
<script type="text/javascript">
Validation.addAllThese([
    [
'validate-mymodule-cc-type-select''Card type doesn\'t match credit card number', function(v, elm) {
        var ccNumberContainer = $(elm.id.substr(0,elm.id.indexOf('
_cc_type')) + '_cc_number');
        return Validation.get('
validate-mymodulecc-type').test(ccNumberContainer.value, ccNumberContainer);
    }],
 ..........
]);

To overwrite the server site validation, you need to overwrite validate() method in your new payment method

 
Magento Community Magento Community
Magento Community
Magento Community
 
bstdevelopment
Member
 
Total Posts:  48
Joined:  2008-04-14
 

thank you - exactly what I was looking for:

but a small correction: $this->setTemplate(’mymodule/form.phtml’); to $this->setTemplate(’mymodule/cc.phtml’);

 
Magento Community Magento Community
Magento Community
Magento Community
 
Airbox Media
Jr. Member
 
Total Posts:  4
Joined:  2009-09-10
 

For those that are having problems with accpting UK Switch / Maestro / Solo with UK PayPal Pro Direct payments it seems there is a bug with Card Verification Number (security number on the back of the card) number box int he checkout process....

The problem is in the file Cc.php it is expecting a 4 digit Card Verification Number (security number on the back of the card) when UK Switch / Maestro / Solo cards only have a 3 digit number.

Locate the Cc.php file in:

app/code/core/Mage/Payment/Model/Method/Cc.php

and where you see this section of code:

- - - - - - - - - - - - - - - - - - - - - -

$verificationExpList = array(
‘VI’ => ‘/^[0-9]{3}$/’, // Visa
‘MC’ => ‘/^[0-9]{3}$/’, // Master Card
‘AE’ => ‘/^[0-9]{4}$/’, // American Express
‘DI’ => ‘/^[0-9]{3}$/’, // Discovery
‘SS’ => ‘/^[0-9]{4}$/’,
‘OT’ => ‘/^[0-9]{3,4}$/’

- - - - - - - - - - - - - - - - - - - - - -

You need to change - - - ‘SS’ => ‘/^[0-9]{4}$/’, - - - to - - - ‘SS’ => ‘/^[0-9]{3}$/’

basically your telling it to look for a 3 digit number and not 4 which is what is causing the errors.

I have tried it on UK Maestro and Solo cards and they seem to work fine

Hope that helps - Jack

 
Magento Community Magento Community
Magento Community
Magento Community
 
G&C
Jr. Member
 
Total Posts:  29
Joined:  2009-09-15
 

Is this still valid in 1.4.1.1 ?

LindyKyaw - 15 April 2008 01:10 PM

You need to overwrite the existing client site and server site validation.

To overwrite client site validation, you need to create a new block for your payment.

1) In you payment class, add

protected $_formBlockType 'mymodule/form';
2) create a block class
class Mage_MyModule_Block_Form extends Mage_Payment_Block_Form_Cc
{
  
protected function _construct()
    
{
        parent
::_construct();
        
$this->setTemplate('mymodule/form.phtml');
    
}
}
3) copy the payment/form/cc.phtml into mymodule/cc.phtml
4) change the class name “validate-cc-type-select” to sth like “validate-mymodule-cc-type-select” and add your validation in the javascript like following
<script type="text/javascript">
Validation.addAllThese([
    [
'validate-mymodule-cc-type-select''Card type doesn\'t match credit card number', function(v, elm) {
        var ccNumberContainer = $(elm.id.substr(0,elm.id.indexOf('
_cc_type')) + '_cc_number');
        return Validation.get('
validate-mymodulecc-type').test(ccNumberContainer.value, ccNumberContainer);
    }],
 ..........
]);

To overwrite the server site validation, you need to overwrite validate() method in your new payment method
 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top