/** * 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; }