/** * Checks/fixes to the PNO/SSN input is valid. * * @param string &$pno Personal number, social security number, ... * @param int $enc {@link KlarnaEncoding PNO Encoding} constant. * @param string $method __METHOD__ * @throws KlarnaException * @return void */ private function checkPNO(&$pno, $enc, $method) { if (!$pno) { throw new KlarnaException("Error in " . $method . ": PNO/SSN not set for customer or given as a parameter!", 50077); } if (!KlarnaEncoding::checkPNO($pno, $enc)) { throw new KlarnaException("Error in " . $method . ": PNO/SSN is not valid!", 50078); } }
/** * @param $data * @return bool */ static function checkDataFromEditPayment($data, $country3) { if (!class_exists('VirtueMartModelUserfields')) { require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php'; } $errors = array(); /* if ($country3 == "DEU") { $consent = vRequest::getVar ('klarna_consent'); if ($consent != 'on') { $errors = vmText::_ ('VMPAYMENT_KLARNA_NO_CONSENT'); } } // todo later $userFieldsModel = VmModel::getModel ('userfields'); $userFields = $userFieldsModel->getUserFields ( 'account' , array('required' => FALSE, 'delimiters' => TRUE, 'captcha' => TRUE, 'system' => FALSE) , array('delimiter_userinfo', 'name', 'username', 'password', 'password2', 'address_type_name', 'address_type', 'user_is_vendor', 'agreed')); $required_shopperfields_vm = Klarnahandler::getKlarnaVMGenericShopperFields (FALSE); $required_shopperfields_bycountry = KlarnaHandler::getKlarnaSpecificShopperFields (); $required_shopperfields = array_merge ($required_shopperfields_vm, $required_shopperfields_bycountry[$country3]); foreach ($userFields as $userField) { if (in_array ($userField->name, $required_shopperfields)) { if (empty($data[$userField->name])) { $errors[] = vmText::_($userField->title); } } } */ // Quick and durty .. but it works $kIndex = "klarna_"; if ($country3 == "SWE") { if (vRequest::getVar('klarna_invoice_type') == 'company') { if (strlen(trim((string) vRequest::getVar('klarna_company_name'))) == 0) { $errors[] = 'VMPAYMENT_KLARNA_COMPANY_NAME'; } } else { if (!KlarnaEncoding::checkPNO($data['socialNumber'], KlarnaEncoding::PNO_SE)) { $errors[] = 'VMPAYMENT_KLARNA_PERSONALORORGANISATIO_NUMBER'; } } } else { if ($data['phone'] == '') { $errors[] = 'VMPAYMENT_KLARNA_PHONE_NUMBER'; } if ($data['street'] == '') { $errors[] = 'VMPAYMENT_KLARNA_STREET_ADRESS'; } if ($data['first_name'] == '') { $errors[] = 'VMPAYMENT_KLARNA_FIRST_NAME'; } if ($data['last_name'] == '') { $errors[] = 'VMPAYMENT_KLARNA_LAST_NAME'; } if ($data['city'] == '') { $errors[] = 'VMPAYMENT_KLARNA_ADDRESS_CITY'; } if ($data['zip'] == '') { $errors[] = 'VMPAYMENT_KLARNA_ADDRESS_ZIP'; } } // German and dutch if ($country3 == "NLD" || $country3 == "DEU") { if ($data['street'] == '') { $errors[] = 'VMPAYMENT_KLARNA_STREET_ADRESS'; } if ($data['house_no'] == '') { $errors[] = 'VMPAYMENT_KLARNA_ADDRESS_HOMENUMBER'; } if ($country3 == "DEU") { if ($data['consent'] != 'on') { $errors[] = 'VMPAYMENT_KLARNA_NO_CONSENT'; } } if ($data['pno_frombirthday'] == '') { $errors[] = 'VMPAYMENT_KLARNA_PERSONALORORGANISATIO_NUMBER'; } if ($data['gender'] == '') { $errors[] = 'VMPAYMENT_KLARNA_SEX'; } } // General /* the email is not in the payment form if ($data['emailAddress'] == '') { $errors[] = 'VMPAYMENT_KLARNA_EMAIL'; } */ // Norwegian, Danish and Finnish if ($country3 == "NOR" || $country3 == "DNK" || $country3 == "FIN") { if ($data['socialNumber'] == '') { $errors[] = 'VMPAYMENT_KLARNA_PERSONALORORGANISATIO_NUMBER'; } } if (!empty($errors)) { $msg = vmText::_('VMPAYMENT_KLARNA_ERROR_TITLE_2'); foreach ($errors as $error) { $msg .= "<li>" . vmText::_($error) . "</li>"; } $option = NULL; self::setKlarnaErrorInSession($msg, $option); return $msg; } return NULL; }
/** * Checks/fixes to the PNO/SSN input is valid. * * @param string &$pno Personal number, social security number, ... * @param int $enc {@link KlarnaEncoding PNO Encoding} constant. * * @throws KlarnaException * @return void */ private function _checkPNO(&$pno, $enc) { if (!$pno) { throw new Klarna_ArgumentNotSetException("PNO/SSN"); } if (!KlarnaEncoding::checkPNO($pno)) { throw new Klarna_InvalidPNOException(); } }