function get_card_type_by_prefix($cc) { $card_type = 0; $prefix = substr($cc, 0, 4); if ($prefix >= 4000 && $prefix <= 4999) { $card_type = 4; //Visa } else { if ($prefix >= 5100 && $prefix <= 5599) { $card_type = 5; //MasterCard } else { if ($prefix >= 3400 && $prefix <= 3499 || $prefix >= 3700 && $prefix <= 3799) { $card_type = 3; //American Express } else { if ($prefix >= 3000 && $prefix <= 3059 || $prefix >= 3600 && $prefix <= 3699 || $prefix >= 3800 && $prefix <= 3899) { $card_type = 8; //Diners Club $is_carte_blanch = $prefix >= 3890 && $prefix <= 3899; //not used } else { if ($prefix >= 3528 && $prefix <= 3589) { $card_type = 1; //JCB } else { switch ($prefix) { case 6011: $card_type = 6; //Discover Card break; case 1800: case 2131: $card_type = 1; //JCB break; case 2014: case 2149: $card_type = 2; //enRoute break; case 5610: $card_type = 7; //Australian BankCard break; } } } } } } return get_card_type($card_type); }
function draw_credit_card($payment_type_row, $T) { global $_TABLES, $_CONF, $_USER; $card_type = get_card_type($payment_type_row['ecom_payment_type']); if ($_GET['op'] == "new_card") { $cardid = draw_new_card(&$T, $card_type); } else { if ($_SESSION['uid'] == 0) { $cardid = draw_user_annom_card(&$T, $card_type, $payment_type_row); } else { $card_res = get_user_card_resource($payment_type_row['ecom_payment_type']); if (DB_numRows($card_res) <= 0) { //No card found, allow them to add chredit card to DB. draw_new_card(&$T, $card_type); } else { $card_row = DB_fetchArray($card_res); if ($card_row['ecom_card_uid'] != $_SESSION['uid']) { echo "This is not your credit card."; exit; } $cardid = draw_card_full($T, $card_row, $card_type, $payment_type_row); } } } return $cardid; }