function pay_method_gateway::set_cc_number in Pay 7
Same name and namespace in other branches
- 6 includes/handlers/pay_method_gateway.inc \pay_method_gateway::set_cc_number()
File
- includes/handlers/pay_method_gateway.inc, line 178
- The base class for credit card payment activities.
Class
- pay_method_gateway
- @file
The base class for credit card payment activities.
Code
function set_cc_number($val) {
$this->cc_number = preg_replace('/[^\\d]/', '', $val);
$orig_cc_type = $this->cc_type;
$this->cc_type = NULL;
$prefix1 = substr($this->cc_number, 0, 1);
$prefix2 = substr($this->cc_number, 0, 2);
$prefix3 = substr($this->cc_number, 0, 3);
$prefix4 = substr($this->cc_number, 0, 4);
$prefix5 = substr($this->cc_number, 0, 5);
$prefix6 = substr($this->cc_number, 0, 6);
switch ($prefix1) {
case 1:
if ($prefix4 == 1800) {
$this->cc_type = 'jcb';
}
break;
case 2:
if ($prefix4 == 2131) {
$this->cc_type = 'jcb';
}
elseif ($prefix4 == 2014) {
$this->cc_type = 'enroute';
}
elseif ($prefix4 == 2149) {
$this->cc_type = 'enroute';
}
break;
case 3:
if (in_array($prefix3, array(
300,
301,
302,
303,
304,
305,
))) {
$this->cc_type = 'diners';
}
elseif (in_array($prefix2, array(
34,
37,
))) {
$this->cc_type = 'amex';
}
elseif (in_array($prefix2, array(
36,
38,
))) {
$this->cc_type = 'diners';
}
else {
$this->cc_type = 'jcb';
}
break;
case 4:
$this->cc_type = 'visa';
if (in_array($prefix4, array(
4903,
4905,
4911,
4936,
))) {
$this->cc_type = 'switch';
}
break;
case 5:
if (in_array($prefix2, array(
51,
52,
53,
54,
55,
))) {
$this->cc_type = 'mc';
}
if ($prefix6 == 564182) {
$this->cc_type = 'switch';
}
if (in_array($prefix4, array(
5018,
5020,
5038,
))) {
$this->cc_type = 'maestro';
}
break;
case 6:
if ($prefix4 == 6011) {
$this->cc_type = 'discover';
}
if ($prefix4 == 6304 || $prefix4 == 6706 || $prefix4 == 6709 || $prefix4 == 6771) {
$this->cc_type = 'laser';
}
if ($prefix6 == 633110 || $prefix4 == 6333) {
$this->cc_type = 'switch';
}
if (in_array($prefix4, array(
6759,
6761,
6763,
))) {
$this->cc_type = 'maestro';
}
if ($prefix4 == 6334 || $prefix4 == 6767) {
$this->cc_type = 'solo';
}
break;
}
if (empty($this->cc_type)) {
$this->cc_type = $orig_cc_type;
}
}