Example #1
0
 /**
  * Filter and validate cc#
  * @return null|string null if ok, error message if error
  */
 public function validateCreditCardNumber($cc)
 {
     require_once 'ccvs.php';
     $validator = new CreditCardValidationSolution();
     if (!$validator->validateCreditCard($cc)) {
         return $validator->CCVSError;
     }
     /** @todo translate error messages from ccvs.php */
     return null;
 }
Example #2
0
 function _validateCard()
 {
     if (!isset($this->card_info['Number'])) {
         return false;
     }
     $validator = new CreditCardValidationSolution();
     $split_exp = split("/", $this->card_info['Expiration']);
     if ($validator->validateCreditCard($this->card_info['Number'], 'en', '', 'Y', $split_exp[0], $split_exp[1])) {
         return true;
     }
     $this->payment->addError($validator->CCVSError);
     return false;
 }
function validate_cc_info($member, $payment, &$vars)
{
    global $t, $db, $config;
    // get a plugin config
    $plugin =& instantiate_plugin('payment', $payment['paysys_id']);
    if (!method_exists($plugin, 'cc_bill')) {
        fatal_error("This plugin ({$payment['paysys_id']}) is not handled by cc_core!");
    }
    $features = $plugin->get_plugin_features();
    ///
    $errors = array();
    // check credit card
    $vars['cc_number'] = preg_replace('/\\D+/', '', $vars['cc_number']);
    $cc = $vars['cc_number'];
    if (strlen($cc) == 0) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR1;
    } elseif (strlen($cc) < 12) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR2;
    } elseif (!$features['skip_cc_number_validation']) {
        // pre-validate credit card info
        require "{$config['root_dir']}/plugins/payment/cc_core/ccvs.inc.php";
        $validator = new CreditCardValidationSolution();
        if (!$validator->validateCreditCard($cc, 'en', $features['cc_types_accepted'])) {
            $errors[] = _PLUG_PAY_CC_CORE_ERROR3 . $validator->CCVSError;
        }
    }
    if ($vars['cc_expire_Month'] < 1 or $vars['cc_expire_Month'] > 12) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR4;
    }
    if ($vars['cc_expire_Year'] < date('Y')) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR5;
    }
    if ($features['maestro_solo_switch']) {
        if ($vars['cc_startdate_Month'] < 1 or $vars['cc_startdate_Month'] > 12) {
            $errors[] = _PLUG_PAY_CC_CORE_ERROR19;
        }
        if ($vars['cc_startdate_Year'] > date('Y')) {
            $errors[] = _PLUG_PAY_CC_CORE_ERROR20;
        }
    }
    if (!strlen($vars['cc_type']) && $features['type_options']) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR6;
    }
    if (!strlen($vars['cc_code']) && $features['code'] && !$vars['renew_cc']) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR7;
    }
    if (!strlen($vars['cc_name']) && $features['name']) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR8;
    }
    if (!strlen($vars['cc_name_f']) && $features['name_f']) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR9;
    }
    if (!strlen($vars['cc_name_l']) && $features['name_l']) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR10;
    }
    if (!strlen($vars['cc_company']) && $features['company'] > 1) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR11;
    }
    if (!strlen($vars['cc_phone']) && $features['phone'] == 2) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR12;
    }
    if (!strlen($vars['cc_housenumber']) && $features['housenumber']) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR13;
    }
    if (!strlen($vars['cc_street'])) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR14;
    }
    if (!strlen($vars['cc_city'])) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR15;
    }
    if (!strlen($vars['cc_state'])) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR16;
    }
    if (!strlen($vars['cc_zip'])) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR17;
    }
    if (!strlen($vars['cc_country'])) {
        $errors[] = _PLUG_PAY_CC_CORE_ERROR18;
    }
    if (method_exists($plugin, 'validate_cc_form')) {
        $errors = array_merge((array) $plugin->validate_cc_form($vars), (array) $errors);
    }
    return $errors;
}