Magento – Credit card number mismatch with credit card type

apice-1.8.1.0paymentsoap

I am using mage api to genertae order but when i generate order using shoppingCartOrder function it gives error "Credit card number mismatch with credit card type."

$proxy->shoppingCartPaymentMethod($sessionId, $quoteId, array(
                    'po_number'    => 'null',
                    'method'       => 'paypal_direct',
                    'cc_cid'       => '123',
                    'cc_owner'     => 'test',
                    'cc_number'    => '4111111111111111',
                    'cc_type'      => 'VI',
                    'cc_exp_year'  => '2022',
                    'cc_exp_month' => '12'
                    )); 

    $cart_order_result=$proxy->shoppingCartOrder($sessionId, $quoteId);

Best Answer

The credit card number is checked against the type using regex, this can be found in Mage_Payment_Model_Method_Cc::validate

But for visa it uses the regex 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', so what it needs is a 4 followed by 12 digits, with an optional 3 digits at the end.

It appears that your number is valid but for some reason the type is still the default OT in the validate code. I would suggest you look into this regex loop to see what is actually happening with your value.

Related Topic