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

Has added credit card types, but validation fails
 
bendtsen
Jr. Member
 
Total Posts:  17
Joined:  2007-09-23
 

Hi

I have added som new credit card types to a payment method, but client side validation fails - how do I edit the client side validation method?

/Bendtsen

 
Magento Community Magento Community
Magento Community
Magento Community
 
bendtsen
Jr. Member
 
Total Posts:  17
Joined:  2007-09-23
 

I think I have found the js responsible for creditcard validation - the file js/prototype/validation.js

The card I have added evaluates like a visa card so I just copied the line that checks the visa and changed the code to VD, but no luck, the new card is still not validated correctly. If I choose to pay with visa there is no problem. What am I missing?

[’validate-cc-type’, ‘Credit card number doesn\’t match credit card type’, function(v, elm) {
// remove credit card number delimiters such as “-” and space
elm.value = removeDelimiters(elm.value);
v = removeDelimiters(v);

var ccTypeContainer = $(elm.id.substr(0,elm.id.indexOf(’_cc_number’)) + ‘_cc_type’);
if (!ccTypeContainer) {
return true;
}
var ccType = ccTypeContainer.value;

// Other card type or switch or solo card
if (ccType == ‘OT’ || ccType == ‘SS’) {
return true;
}

// Credit card type detecting regexp
var ccTypeRegExp = {
‘VI’: new RegExp(’^4[0-9]{12}([0-9]{3})?$’),
‘VD’: new RegExp(’^4[0-9]{12}([0-9]{3})?$’), // THIS IS THE LINE I HAVE ADDED
‘MC’: new RegExp(’^5[1-5][0-9]{14}$’),
‘AE’: new RegExp(’^3[47][0-9]{13}$’),
‘DI’: new RegExp(’^6011[0-9]{12}$’)
};

// Matched credit card type
var ccMatchedType = ‘’;
$H(ccTypeRegExp).each(function (pair) {
if (v.match(pair.value)) {
ccMatchedType = pair.key;
throw $break;
}
});

if(ccMatchedType != ccType) {
return false;
}

return true;
}],
[’validate-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-cc-type’).test(ccNumberContainer.value, ccNumberContainer);
}],

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

check http://www.magentocommerce.com/boards/viewthread/6273/

 
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top