/** * 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)); if ($order->info['payment_method'] === 'ratepay_lastschrift' && is_null($orderId)) { $payment = Loader::getRatepayPayment($order->info['payment_method']); $bankAccount = $payment->getBankData(); $bankAccountInfo = new BankInfo(); $bankAccountInfo->setOwner($bankAccount['owner']); if (!empty($bankAccount['iban'])) { $bankAccountInfo->setIban($bankAccount['iban']); if (!empty($bankAccount['bic-swift'])) { $bankAccountInfo->setBic($bankAccount['bic-swift']); } } else { $bankAccountInfo->setAccountNumber($bankAccount['bank-account-number']); $bankAccountInfo->setBankCode($bankAccount['bank-code']); } $bankAccountInfo->setBankName($bankAccount['bank-name']); $customerInfo->setBankAccount($bankAccountInfo); } $customerInfo->setCreditInquiry('yes')->setDateOfBirth(Db::getCustomersDob($orderId, Session::getSessionEntry('customer_id')))->setEmail($order->customer['email_address'])->setFax(Db::getCustomersFax($orderId, Session::getSessionEntry('customer_id')))->setPhone($order->customer['telephone'])->setFirstName(is_null($orderId) ? $order->customer['firstname'] : Db::getRatepayOrderDataEntry($orderId, 'firstname'))->setGender(is_null($orderId) ? $order->customer['gender'] : Db::getRatepayOrderDataEntry($orderId, 'gender'))->setIp(is_null($orderId) ? Data::getCustomerIp() : Db::getRatepayOrderDataEntry($orderId, 'ip_address'))->setLastName(is_null($orderId) ? $order->customer['lastname'] : Db::getRatepayOrderDataEntry($orderId, 'lastname'))->setNationality(is_array($order->customer['country']) ? $order->customer['country']['iso_code_2'] : Db::getRatepayOrderDataEntry($orderId, 'customers_country_code')); $vatId = Db::getCustomersVatId($orderId, Session::getSessionEntry('customer_id')); if (!empty($order->customer['company']) && !empty($vatId)) { $customerInfo->setCompany($order->customer['company'])->setVatId($vatId); } return $customerInfo; }
/** * 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," . "firstname," . "lastname," . "ip_address," . "billing_country_code," . "shipping_country_code," . "fax," . "customers_country_code," . "gender" . ") VALUES ('" . tep_db_input($orderId) . "', '" . tep_db_input(Session::getRpSessionEntry('transactionId')) . "', '" . tep_db_input(Session::getRpSessionEntry('transactionShortId')) . "', '" . tep_db_input(Session::getRpSessionEntry('descriptor')) . "', '" . tep_db_input(Db::getCustomersDob(null, Session::getSessionEntry('customer_id'))) . "', '" . tep_db_input($order->customer['firstname']) . "', '" . tep_db_input($order->customer['lastname']) . "', '" . tep_db_input(Data::getCustomerIp()) . "', '" . tep_db_input($order->billing['country']['iso_code_2']) . "', '" . tep_db_input($order->delivery['country']['iso_code_2']) . "', '" . tep_db_input(Db::getCustomersFax(null, Session::getSessionEntry('customer_id'))) . "','" . tep_db_input(Session::getRpSessionEntry('customers_country_code')) . "','" . tep_db_input(Db::getXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_gender')) . "')"; tep_db_query($sql); self::setRpOrderItems($order, $orderId, $payment); }
/** * This method get the selected languange and has to be rewritten * return DE for German Calculator. Everything else will be English. * @return string */ public function getLanguage() { if (Session::getSessionEntry('language') == 'german') { return 'DE'; } else { return 'EN'; } }
/** * 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 (!$this->isInfoVisited()) { if ($this->_isPhoneNeeded()) { if (Globals::hasPostEntry($this->code . '_phone') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_phone'))) { $phone = Globals::getPostEntry($this->code . '_phone'); if ($this->_isPhoneValid($phone)) { Db::setXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_telephone', $phone); $order->customer['telephone'] = $phone; } else { $this->error['PHONE'] = 'INVALID'; } } else { $this->error['PHONE'] = 'MISSING'; } } if ($this->_isDobNeeded()) { if (Globals::hasPostEntry($this->code . '_birthdate') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_birthdate'))) { $dob = Globals::getPostEntry($this->code . '_birthdate'); if (!$this->_isDobValid($dob)) { $this->error['DOB'] = 'INVALID'; } elseif (!$this->_isAdult($dob)) { $this->error['DOB'] = 'YOUNGER'; } else { $dobArr = explode('.', $dob); $dateStr = $dobArr[2] . "-" . $dobArr[1] . "-" . $dobArr[0] . " 00:00:00"; Db::setXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_dob', $dateStr); } } else { $this->error['DOB'] = 'MISSING'; } } if ($this->_isCompanyNeeded()) { if (Globals::hasPostEntry($this->code . '_company') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_company'))) { $company = Globals::getPostEntry($this->code . '_company'); $order->customer['company'] = $company; $order->billing['company'] = $company; $dbInput = tep_db_input(Db::getXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_default_address_id')); tep_db_query("UPDATE " . TABLE_ADDRESS_BOOK . " " . "SET entry_company = '" . tep_db_prepare_input($company) . "' " . "WHERE address_book_id = '" . $dbInput . "'"); } else { $this->error['VATID'] = 'MISSING'; } } if ($this->_isVatIdNeeded()) { if (Globals::hasPostEntry($this->code . '_vatid') && !Data::betterEmpty(Globals::getPostEntry($this->code . '_vatid'))) { Db::setXtCustomerEntry(Session::getSessionEntry('customer_id'), 'customers_vat_id', Globals::getPostEntry($this->code . '_vatid')); } else { $this->error['VATID'] = 'MISSING'; } } if (empty($this->error)) { $this->setInfoVisited(true); Session::setRpSessionEntry('basketAmount', Data::getBasketAmount($order)); //$url = tep_href_link(FILENAME_CHECKOUT_CONFIRMATION, '', 'SSL'); $url = tep_href_link($this->_getNextStepPayment(), '', 'SSL'); } else { $this->error = urlencode($this->_getErrorString($this->error)); $url = tep_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $this->error, 'SSL'); } tep_redirect($url); } }
/** * Retrieve a request shipping item from the given order * * @param order $order * @return array */ public static function getShippingData(order $order) { $shipping = array(); $session = Session::getSessionEntry('ratepay'); if (array_key_exists('shipping_cost', $order->info) && $order->info['shipping_cost'] > 0) { $shipping['qty'] = 1; $shipping['name'] = $order->info['shipping_method']; $shipping['id'] = 'SHIPPING'; $shipping['unitPrice'] = self::getLocalePrice($order->info['shipping_cost'], $order); $shipping['totalPrice'] = self::getLocalePrice($order->info['shipping_cost'], $order); $shipping['tax'] = self::getShippingTaxAmount($order); Session::setRpSessionEntry('shipping', $shipping); } else { if (array_key_exists('shipping', $session)) { $shipping = Session::getRpSessionEntry('shipping'); } } return $shipping; }