/** * 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; }
/** * This constructor set's all properties for the ratepay_rate object */ public function __construct() { global $order; $this->code = 'ratepay_rate'; $this->version = '2.2.3'; $this->shopVersion = str_replace(' ', '', str_replace("xt:Commerce v", "", PROJECT_VERSION)); $this->shopSystem = 'xt:Commerce'; $this->title = MODULE_PAYMENT_RATEPAY_RATE_TEXT . " (" . $this->version . ")"; $this->public_title = MODULE_PAYMENT_RATEPAY_RATE_TEXT_TITLE; $this->description = utf8_decode(MODULE_PAYMENT_RATEPAY_RATE_TEXT_DESCRIPTION); $this->enabled = MODULE_PAYMENT_RATEPAY_RATE_STATUS == 'True' ? true : false; $this->minDe = MODULE_PAYMENT_RATEPAY_RATE_MIN_DE; $this->maxDe = MODULE_PAYMENT_RATEPAY_RATE_MAX_DE; $this->minAt = MODULE_PAYMENT_RATEPAY_RATE_MIN_AT; $this->maxAt = MODULE_PAYMENT_RATEPAY_RATE_MAX_AT; $this->sandbox = MODULE_PAYMENT_RATEPAY_RATE_SANDBOX == 'True' ? true : false; $this->logging = MODULE_PAYMENT_RATEPAY_RATE_LOGGING == 'True' ? true : false; $this->sort_order = MODULE_PAYMENT_RATEPAY_RATE_SORT_ORDER; $country = $order->billing['country']['iso_code_2']; if (!is_array($order->billing['country'])) { $country = rpSession::getRpSessionEntry('customers_country_code'); } if (!is_null(rpSession::getRpSessionEntry('orderId'))) { $country = rpDb::getRatepayOrderDataEntry(rpSession::getRpSessionEntry('orderId'), 'customers_country_code'); } if (!is_null(rpSession::getRpSessionEntry('countryCode'))) { $country = rpSession::getRpSessionEntry('countryCode'); } $this->_setCredentials($country); if ((int) MODULE_PAYMENT_RATEPAY_RATE_ORDER_STATUS_ID > 0) { $this->order_status = MODULE_PAYMENT_RATEPAY_RATE_ORDER_STATUS_ID; } if (is_object($order)) { $this->update_status(); } }
/** * Call PAYMENT_CHANGE with the subtype credit * and add a credit item to the order */ public static function creditAction() { $post = rpGlobals::getPost(); $orderId = rpGlobals::getPostEntry('order_number'); $creditAmount = floatval($post['voucherAmount'] . '.' . $post['voucherAmountKomma']); $deliveredBasketAmount = rpDb::getRpBasketAmount($orderId); if ($creditAmount <= $deliveredBasketAmount) { $order = new order($orderId); $rate = $order->info['payment_method'] == 'ratepay_rate' ? true : false; $payment = rpLoader::getRatepayPayment($order->info['payment_method']); $transactionId = rpDb::getRatepayOrderDataEntry($orderId, 'transaction_id'); $transactionShortId = rpDb::getRatepayOrderDataEntry($orderId, 'transaction_short_id'); if ($rate) { $subType = 'return'; $postCredit = self::getRefundPostData($post); } else { $subType = 'credit'; } $postCredit['order_number'] = $post['order_number']; $postCredit['voucherAmount'] = $post['voucherAmount']; $postCredit['voucherAmountKomma'] = $post['voucherAmountKomma']; $data = array('HeadInfo' => rpRequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId, $subType), 'BasketInfo' => rpRequestMapper::getBasketInfoModel($order, $orderId, $postCredit, $subType), 'PaymentInfo' => rpRequestMapper::getPaymentInfoModel($order, $orderId, $postCredit, $subType)); $requestService = new rpRequestService($payment->sandbox, $data); $result = $requestService->callPaymentChange(); rpDb::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse()); if (!array_key_exists('error', $result)) { rpSession::setRpSessionEntry('message_css_class', 'messageStackSuccess'); rpSession::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_SUCCESS); rpDb::setRpCreditItem(rpGlobals::getPost(), $rate ? 1 : 0); rpDb::setRpHistoryEntry($orderId, rpData::getCreditItem($post), 'PAYMENT_CHANGE', $subType); rpDb::addCreditToShop($orderId, $post); rpDb::updateShopOrderTotals($orderId); } else { rpSession::setRpSessionEntry('message_css_class', 'messageStackError'); rpSession::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_ERROR); } if ($rate) { xtc_redirect(xtc_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL')); } else { self::deliverAction(self::getDeliverPostArray($orderId, $post['items'])); } } else { rpSession::setRpSessionEntry('message_css_class', 'messageStackError'); rpSession::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_ERROR); xtc_redirect(xtc_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL')); } }