/**
  * Retrieve a customerInfo model filled with the addresses and the customer data
  * 
  * @param order $order
  * @param int $orderId
  * @return CustomerInfo
  */
 public static function getCustomerInfoModel(order $order, $orderId = null)
 {
     $customerInfo = new CustomerInfo();
     $customerInfo->setBillingAddressInfo(self::getBillingAdressInfo($order, $orderId))->setShippingAddressInfo(self::getShippingAdressInfo($order, $orderId));
     $customerInfo->setCreditInquiry('yes')->setDateOfBirth(rpDb::getCustomersDob($orderId, rpSession::getSessionEntry('customer_id')))->setEmail($order->customer['email_address'])->setFax(rpDb::getCustomersFax($orderId, rpSession::getSessionEntry('customer_id')))->setPhone($order->customer['telephone'])->setFirstName(is_null($orderId) ? $order->customer['firstname'] : rpDb::getShopOrderDataEntry($orderId, 'customers_firstname'))->setGender(is_null($orderId) ? $order->customer['gender'] : rpDb::getRatepayOrderDataEntry($orderId, 'gender'))->setIp(is_null($orderId) ? rpData::getCustomerIp() : $order->customer['cIP'])->setLastName(is_null($orderId) ? $order->customer['lastname'] : rpDb::getShopOrderDataEntry($orderId, 'customers_lastname'))->setNationality(is_array($order->customer['country']) ? $order->customer['country']['iso_code_2'] : rpDb::getRatepayOrderDataEntry($orderId, 'customers_country_code'));
     $vatId = rpDb::getCustomersVatId($orderId, rpSession::getSessionEntry('customer_id'));
     if (!empty($order->customer['company']) && !empty($vatId)) {
         $customerInfo->setCompany($order->customer['company'])->setVatId($vatId);
     }
     if ($order->info['payment_method'] === 'ratepay_sepa' && is_null($orderId)) {
         $payment = rpLoader::getRatepayPayment($order->info['payment_method']);
         $bankAccount = $payment->getBankData();
         $bankAccountInfo = new rpBankaccountInfo();
         $bankAccountInfo->setAccountNumber($bankAccount['accountnumber']);
         $bankAccountInfo->setBankName($bankAccount['bankname']);
         $bankAccountInfo->setOwner($bankAccount['owner']);
         if (!empty($bankAccount['bankcode'])) {
             $bankAccountInfo->setBankAccount($bankAccount['bankcode']);
         }
         $customerInfo->setBankAccount($bankAccountInfo);
     }
     return $customerInfo;
 }
 /**
  * Is called after checkout_payment.php is confirmed,
  * checks if all needed customer data available or 
  * redirect the customer to the checkout_payment.php
  * with a error message otherwise the user get to the
  * ratepay terms page
  * 
  * @global order $order
  */
 public function pre_confirmation_check()
 {
     global $order;
     if (strtoupper($this->code) == 'RATEPAY_SEPA' && !rpGlobals::hasPostEntry($this->code . '_conditions')) {
         $this->error['CONDITIONS'] = 'MISSING';
     }
     if ($this->_isPhoneNeeded()) {
         if (rpGlobals::hasPostEntry($this->code . '_phone') && !rpData::betterEmpty(rpGlobals::getPostEntry($this->code . '_phone'))) {
             rpDb::setXtCustomerEntry(rpSession::getSessionEntry('customer_id'), 'customers_telephone', rpGlobals::getPostEntry($this->code . '_phone'));
             $order->customer['telephone'] = rpGlobals::getPostEntry($this->code . '_phone');
         } else {
             $this->error['PHONE'] = 'MISSING';
         }
     }
     if ($this->_isDobNeeded()) {
         if (rpGlobals::hasPostEntry($this->code . '_birthdate') && !rpData::betterEmpty(rpGlobals::getPostEntry($this->code . '_birthdate'))) {
             if (!$this->_isDobValid(rpGlobals::getPostEntry($this->code . '_birthdate'))) {
                 $this->error['DOB'] = 'INVALID';
             } else {
                 $dob = rpGlobals::getPostEntry($this->code . '_birthdate');
                 $dateStr = substr(xtc_date_raw($dob), 6, 2) . "." . substr(xtc_date_raw($dob), 4, 2) . "." . substr(xtc_date_raw($dob), 0, 4) . " 00:00:00";
                 $dateStr = substr(xtc_date_raw($dob), 0, 4) . '-' . substr(xtc_date_raw($dob), 4, 2) . '-' . substr(xtc_date_raw($dob), 6, 2) . ' 00:00:00';
                 rpDb::setXtCustomerEntry(rpSession::getSessionEntry('customer_id'), 'customers_dob', $dateStr);
             }
         } else {
             $this->error['DOB'] = 'MISSING';
         }
     }
     if ($this->_isCompanyNeeded()) {
         if (rpGlobals::hasPostEntry($this->code . '_company') && !rpData::betterEmpty(rpGlobals::getPostEntry($this->code . '_company'))) {
             $company = rpGlobals::getPostEntry($this->code . '_company');
             $order->customer['company'] = $company;
             $order->billing['company'] = $company;
             $dbInput = xtc_db_input(rpDb::getXtCustomerEntry(rpSession::getSessionEntry('customer_id'), 'customers_default_address_id'));
             xtc_db_query("UPDATE " . TABLE_ADDRESS_BOOK . " " . "SET entry_company = '" . xtc_db_prepare_input($company) . "' " . "WHERE address_book_id = '" . $dbInput . "'");
         } else {
             $this->error['VATID'] = 'MISSING';
         }
     }
     if ($this->_isVatIdNeeded()) {
         if (rpGlobals::hasPostEntry($this->code . '_vatid') && !rpData::betterEmpty(rpGlobals::getPostEntry($this->code . '_vatid'))) {
             rpDb::setXtCustomerEntry(rpSession::getSessionEntry('customer_id'), 'customers_vat_id', rpGlobals::getPostEntry($this->code . '_vatid'));
         } else {
             $this->error['VATID'] = 'MISSING';
         }
     }
     if (!$this->_isAdult(rpDb::getCustomersDob(null, rpSession::getSessionEntry('customer_id')))) {
         $this->error['DOB'] = 'YOUNGER';
     }
     if (!empty($this->error)) {
         $error = urlencode($this->_getErrorString($this->error));
         $url = xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $error, 'SSL');
         xtc_redirect($url);
     }
 }
Example #3
0
 /**
  * Insert ratepay order data
  *
  * @param order $order
  * @param int $orderId
  */
 public static function setRatepayOrderData(order $order, $orderId)
 {
     $payment = $order->info['payment_method'];
     $sql = "INSERT INTO " . $payment . "_orders (" . "order_number, " . "transaction_id, " . "transaction_short_id, " . "descriptor," . "customers_birth," . "fax," . "customers_country_code," . "gender" . ") VALUES ('" . xtc_db_input($orderId) . "', '" . xtc_db_input(rpSession::getRpSessionEntry('transactionId')) . "', '" . xtc_db_input(rpSession::getRpSessionEntry('transactionShortId')) . "','" . xtc_db_input(rpSession::getRpSessionEntry('descriptor')) . "','" . xtc_db_input(rpDb::getCustomersDob(null, rpSession::getSessionEntry('customer_id'))) . "','" . xtc_db_input(rpDb::getCustomersFax(null, rpSession::getSessionEntry('customer_id'))) . "','" . xtc_db_input(rpSession::getRpSessionEntry('customers_country_code')) . "','" . xtc_db_input(rpDb::getXtCustomerEntry(rpSession::getSessionEntry('customer_id'), 'customers_gender')) . "')";
     xtc_db_query($sql);
     self::setRpOrderItems($order, $orderId, $payment);
 }