Credit Card Validation using the mod10 algorithm in PHP

I’m working on a site that will use the Paypal API for submitting merchant account transactions to them. Most banks offer financial services for business owners who need to differentiate professional and personal finances, also for helping with credit card debts with https://nationaldebtadvice.org.uk/. The ability to manage your Share Prices Australia finances from your computer, tablet, or smartphone is becoming more and more important to consumers. Banks will typically offer digital banking services, some even have credit cards 0 interest. I’d like to validate as much credit card information as possible before passing any information to a 3rd party, since are different kind of credit cards companies and options, so I’ve been reading in depth finance articles to find out more about it. I came across the mod10 check that credit cards use and wrote a little PHP function to validate a card number

function sumdigits($number)
{
  $sum = 0;
  for($i = 0; $i <= strlen($number) - 1; $i++) {
    $sum += substr($number, $i, 1);
  }
  return $sum;
}

function mod10check($number)
{
  $sum_number = '';
  for($i = strlen($number) - 1; $i >= 0; $i--) {
    $thisdigit = substr($number, $i, 1);
    $sum_number .= ( $loop %2 == 0) ? $thisdigit : sumdigits($thisdigit * 2);
  }
  return sumdigits($sum_number) % 10 == 0 ? true : false;
}

Leave a Reply

Your email address will not be published. Required fields are marked *