Forums / Built-in Shipping and Payment Modules / can't generate order using valid credit card

can't generate order using valid credit card

Locked

Views: 2,683

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
5 Nov 2008, 10:23 AM
#1
feolindo avatar

feolindo

New Zenner

Join Date:
Aug 2008
Posts:
45
Plugin Contributions:
0

can't generate order using valid credit card

I'm testing the system I've set up but when I get to the payment info page and enter valid cc info I get an error message that says it can't continue. I know the card is valid and there's plenty of space on it so I don't understand.
Is this because I don't have a payment gateway set up yet?
any ideas would be appreciated.

5 Nov 2008, 10:33 AM
#2
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: can't generate order using valid credit card

What payment module are you using?

If it is the standard C.Card module, then it could be that the MOD-10 algorithm inherent in the code does not recognise the card's first 4 digits.

First, you need to test the module using the C.Card test number:

4111111111111111

Set the expiry date as any time in the future.

Set the CVV number as 999

Then submit the test order

If this works, then the software is functioning. If you still get the same error, then you have a faulty bit of code somewhere.

If you do not intend using offline c.card, this might not matter much, becuase a payment gateway service applies their own processing.

However, if you find the error occurs AFTER you set up a 3rd party gateway, then you have a code issue that will need resolving.

5 Nov 2008, 10:48 AM
#3
feolindo avatar

feolindo

New Zenner

Join Date:
Aug 2008
Posts:
45
Plugin Contributions:
0

Re: can't generate order using valid credit card

Thanks for the quick reply.
For the time being I have it set up to use the "credit card - offline processing" module. The store owner though will eventually be using a payment gateway like paypal website payments pro or authorize.net.
Anyway, that said, I punched in the test number and other info as you suggested and the whole thing worked fine. I'd like to be able to give the boss a clear answer as to why using a valid card for the test didn't work.
Any suggestions in that area because frankly I still don't understand.
Thanks again.

5 Nov 2008, 11:25 AM
#4
fairestcape avatar

fairestcape

Totally Zenned

Join Date:
Mar 2008
Location:
Cape Town & London (depends on the season)
Posts:
2,957
Plugin Contributions:
0

Re: can't generate order using valid credit card

The MOD-10 (or Luhn) algorithm is a CHECKSUM procedure that is widely used in ID or Credit Card number validation.

Basically, it's a simple mathematical formula that is applied to these types of numbers to make sure that the user has input a VALID number - it does not verify the authenticity of the card and its owner - it just says:

"yes, this number that the user has entered passes the Luhn test, and is therefore valid as a number commonly used by credit cards."

If the user enters the digits incorrectly, the Luhn algorithm, will not calculate properly, and deliver a message saying that the card number is "not a valid card number"

This does NOT mean the card is not "authorised" - just that ZC's Luhn algorithm cannot validate its NUMBER.

The algorithm for ZC is stored in a file called:

cc_validation.php

in the includes/classes folder.

Take a look at the following bit of code from that file to get a glimpse of its structure (no need to understand the code itself)

<?php
/**
 * cc_validation Class.
 *
 * @package classes
 * @copyright Copyright 2003-2007 Zen Cart Development Team
 * @copyright Portions Copyright 2003 osCommerce
 * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0
 * @version $Id: cc_validation.php 7379 2007-11-08 03:58:07Z drbyte $
 */
if (!defined('IS_ADMIN_FLAG')) {
  die('Illegal Access');
}
/**
 * cc_validation Class.
 * Class to validate credit card numbers etc
 *
 * @package classes
 */
class cc_validation extends base {
  var $cc_type, $cc_number, $cc_expiry_month, $cc_expiry_year;

    function validate($number, $expiry_m, $expiry_y, $start_m = null, $start_y = null) {
    $this->cc_number = ereg_replace('[^0-9]', '', $number);

      // Check specific card-types based on first 6 digits:
      $NumberLeft6 = substr($this->cc_number, 0, 6);

      /***** SWITCH *****/
      if (( (($NumberLeft6 >= 490302) && ($NumberLeft6 <= 490309))
                || (($NumberLeft6 >= 490335) && ($NumberLeft6 <= 490339))
                || (($NumberLeft6 >= 491101) && ($NumberLeft6 <= 491102))
                || (($NumberLeft6 >= 491174) && ($NumberLeft6 <= 491182))
                || (($NumberLeft6 >= 493600) && ($NumberLeft6 <= 493699))
                ||  ($NumberLeft6 == 564182)
                || (($NumberLeft6 >= 633300) && ($NumberLeft6 <= 633349))
                || (($NumberLeft6 >= 675900) && ($NumberLeft6 <= 675999))
                ) && (ereg('[0-9]{16}|[0-9]{18}|[0-9]{19}', $this->cc_number))  and CC_ENABLED_SWITCH=='1') {
          $this->cc_type = "Switch";
      }

      /***** SOLO *****/
      elseif (( (($NumberLeft6 >= 633450) && ($NumberLeft6 <= 633460))
                || (($NumberLeft6 >= 633462) && ($NumberLeft6 <= 633472))
                || (($NumberLeft6 >= 633474) && ($NumberLeft6 <= 633475))
                ||  ($NumberLeft6 == 633477)
                || (($NumberLeft6 >= 633479) && ($NumberLeft6 <= 633480))
                || (($NumberLeft6 >= 633482) && ($NumberLeft6 <= 633489))
                ||  ($NumberLeft6 == 633498)
                || (($NumberLeft6 >= 676700) && ($NumberLeft6 <= 676799))
                ) && (ereg('[0-9]{16}|[0-9]{18}|[0-9]{19}', $this->cc_number))  and CC_ENABLED_SOLO=='1') {
          $this->cc_type = "Solo";
      }

      /***** JCB *****/
      elseif (( (($NumberLeft6 >= 352800) && ($NumberLeft6 <= 358999))
//              ||  ($NumberLeft6 == 411111)
              )
              && (ereg('[0-9]{16}', $this->cc_number))  and CC_ENABLED_JCB=='1') {
          $this->cc_type = "JCB";
      }

      /***** MAESTRO *****/
      elseif (( (($NumberLeft6 >= 493698) && ($NumberLeft6 <= 493699))
                ||  ($NumberLeft6 == 490303)
                || (($NumberLeft6 >= 633302) && ($NumberLeft6 <= 633349))
                || (($NumberLeft6 >= 675900) && ($NumberLeft6 <= 675999))
                || (($NumberLeft6 >= 500000) && ($NumberLeft6 <= 509999))
                || (($NumberLeft6 >= 560000) && ($NumberLeft6 <= 589999))
                || (($NumberLeft6 >= 600000) && ($NumberLeft6 <= 699999))
                ) && (ereg('[0-9]{16}([0-9]{3})', $this->cc_number))  and CC_ENABLED_MAESTRO=='1') {
          $this->cc_type = "Maestro";
      }

      /***** VISA *****/
      elseif (( (($NumberLeft6 >= 400000) && ($NumberLeft6 <= 499999))
                // ensure we exclude AMT only cards
                && !( (($NumberLeft6 >= 490300) && ($NumberLeft6 <= 490301))
                      || (($NumberLeft6 >= 490310) && ($NumberLeft6 <= 490334))
                      || (($NumberLeft6 >= 490340) && ($NumberLeft6 <= 490399))
                      || (($NumberLeft6 >= 490400) && ($NumberLeft6 <= 490409))
                      ||  ($NumberLeft6 == 490419)
                      ||  ($NumberLeft6 == 490451)
                      ||  ($NumberLeft6 == 490459)
                      ||  ($NumberLeft6 == 490467)
                      || (($NumberLeft6 >= 490475) && ($NumberLeft6 <= 490478))
                      || (($NumberLeft6 >= 490500) && ($NumberLeft6 <= 490599))
                      || (($NumberLeft6 >= 491103) && ($NumberLeft6 <= 491173))
                      || (($NumberLeft6 >= 491183) && ($NumberLeft6 <= 491199))
                      || (($NumberLeft6 >= 492800) && ($NumberLeft6 <= 492899))
                      || (($NumberLeft6 >= 498700) && ($NumberLeft6 <= 498799))
                      )
                ) && (ereg('[0-9]{16}|[0-9]{13}', $this->cc_number))  and CC_ENABLED_VISA=='1') {
          $this->cc_type = 'Visa';

    // traditional CC hash checks:
    } elseif (ereg('^4[0-9]{12}([0-9]{3})?$', $this->cc_number) and CC_ENABLED_VISA=='1') {
      $this->cc_type = 'Visa';
    } elseif (ereg('^5[1-5][0-9]{14}$', $this->cc_number) and CC_ENABLED_MC=='1') {
      $this->cc_type = 'MasterCard';
    } elseif (ereg('^3[47][0-9]{13}$', $this->cc_number) and CC_ENABLED_AMEX=='1') {
      $this->cc_type = 'American Express';
    } elseif (ereg('^3(0[0-5]|[68][0-9])[0-9]{11}$', $this->cc_number) and CC_ENABLED_DINERS_CLUB=='1') {
      $this->cc_type = 'Diners Club';
    } elseif (ereg('^6011[0-9]{12}$', $this->cc_number) and CC_ENABLED_DISCOVER=='1') {
      $this->cc_type = 'Discover';
    } elseif (ereg('^(3[0-9]{4}|2131|1800)[0-9]{11}$', $this->cc_number) and CC_ENABLED_JCB=='1') {
      $this->cc_type = 'JCB';
    } elseif (ereg('^5610[0-9]{12}$', $this->cc_number) and CC_ENABLED_AUSTRALIAN_BANKCARD=='1') {
      $this->cc_type = 'Australian BankCard';
    } else {
      return -1;
    }

Look at the first 6 numbers and card type you used initially

It's likely that data is not listed in this code - and that will explain why the Luhn algorithm failed to validate the number.

Payment Gateways have more sophisticated validation software, and usually accept a far greater range of card types and numbers.

Of course, you can modify the cc_validation.php file to recognise the card type and initial number sequence of your card!

6 Nov 2008, 2:59 AM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,515
Plugin Contributions:
176

Re: can't generate order using valid credit card

feolindo:

I get an error message that says it can't continue.
I'd probably be able to give you some specific help if you were to actually quote the "actual" error message instead of "says it can't continue".

Do you have your credit card's type enabled in Admin->Configuration->Credit Cards?

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

6 Nov 2008, 6:27 AM
#6
feolindo avatar

feolindo

New Zenner

Join Date:
Aug 2008
Posts:
45
Plugin Contributions:
0

Re: can't generate order using valid credit card

Thank you fairestcape for that comprehensive reply.
Dr Byte: I appreciate everything you folks to do help and you're right; I should have been more precise.