/** * Save rate details to the db * * @param int$orderId */ protected function _saveRateDetails($orderId) { $data = array('order_number' => $orderId, 'total_amount' => rpSession::getRpSessionEntry('ratepay_rate_total_amount'), 'amount' => rpSession::getRpSessionEntry('ratepay_rate_amount'), 'interest_amount' => rpSession::getRpSessionEntry('ratepay_rate_interest_amount'), 'service_charge' => rpSession::getRpSessionEntry('ratepay_rate_service_charge'), 'annual_percentage_rate' => rpSession::getRpSessionEntry('ratepay_rate_annual_percentage_rate'), 'monthly_debit_interest' => rpSession::getRpSessionEntry('ratepay_rate_monthly_debit_interest'), 'number_of_rates' => rpSession::getRpSessionEntry('ratepay_rate_number_of_rates'), 'rate' => rpSession::getRpSessionEntry('ratepay_rate_rate'), 'last_rate' => rpSession::getRpSessionEntry('ratepay_rate_last_rate')); rpDb::setRatepayRateDetails($data); }
/** * Retrieve the encoded bankdata * * @return array */ public function getBankData() { $customerId = (string) $_SESSION['customer_id']; $piEncryption = new Pi_Util_Encryption_XtCommerceEncryption(); if (!empty($customerId)) { $bankdata = $piEncryption->loadBankdata($customerId); } else { $bankdata = array('owner' => rpSession::getRpSessionEntry('rp-account-holder'), 'accountnumber' => rpSession::getRpSessionEntry('rp-account-number'), 'bankcode' => rpSession::getRpSessionEntry('rp-sort-code'), 'bankname' => rpSession::getRpSessionEntry('rp-bank-name')); } return $bankdata; }
/** * 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')); } }
/** * Call PAYMENT_REQUEST request * * @global order $order * @param string $transactionId * @param string$transactionShortId * @return array */ protected function _paymentRequest($transactionId, $transactionShortId) { global $order; rpSession::setRpSessionEntry('countryCode', $order->customer['country']['iso_code_2']); $data = array('HeadInfo' => rpRequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId), 'CustomerInfo' => rpRequestMapper::getCustomerInfoModel($order), 'BasketInfo' => rpRequestMapper::getBasketInfoModel($order), 'PaymentInfo' => rpRequestMapper::getPaymentInfoModel($order)); $requestService = new rpRequestService($this->sandbox, $data); $result = $requestService->callPaymentRequest(); rpDb::xmlLog($order, $requestService->getRequest(), 'N/A', $requestService->getResponse()); return $result; }
</td> <td class="dataTableContent"><?php echo $entry['date']; ?> </td> </tr> <?php } ?> </table> </td> </tr> </table> </td> </tr> </table> </td> </tr> </table> <!-- body_eof //--> <!-- footer //--> <?php require DIR_WS_INCLUDES . 'footer.php'; ?> <!-- footer_eof //--> </body> </html> <?php require DIR_WS_INCLUDES . 'application_bottom.php'; rpSession::cleanRpSession();
/** * Retrieve paymentInfo model * * @param order $order * @param int $orderId * @return rpPaymentInfo */ public static function getPaymentInfoModel(order $order, $orderId = null, array $post = array(), $subType = false) { $paymentInfo = new rpPaymentInfo(); $paymentInfo->setCurrency($order->info['currency']); $paymentInfo->setMethod(rpData::getRpPaymentMethod($order->info['payment_method'])); if ($subType != 'credit' && $subType != 'return' && $subType != 'cancellation') { $paymentInfo->setAmount(rpData::getPaymentAmount($order, $orderId, $post)); if ($order->info['payment_method'] == 'ratepay_rate') { if (is_null($orderId)) { $paymentInfo->setDebitType('BANK-TRANSFER')->setInstallmentAmount(rpSession::getRpSessionEntry('ratepay_rate_rate'))->setInstallmentNumber(rpSession::getRpSessionEntry('ratepay_rate_number_of_rates'))->setInterestRate(rpSession::getRpSessionEntry('ratepay_rate_interest_rate'))->setLastInstallmentAmount(rpSession::getRpSessionEntry('ratepay_rate_last_rate'))->setPaymentFirstDay(rpSession::getRpSessionEntry('ratepay_payment_firstday')); } else { $details = rpDb::getRatepayRateDetails($orderId); $paymentInfo->setDebitType('BANK-TRANSFER')->setInstallmentAmount($details['rate'])->setInstallmentNumber($details['number_of_rates'])->setInterestRate($details['interest_amount'])->setLastInstallmentAmount($details['last_rate'])->setPaymentFirstDay($details['payment_firstday']); } } } return $paymentInfo; }
public function selection() { global $order; $display = parent::selection(); if (!is_null($display)) { $minVarName = 'min' . ucfirst(strtolower($order->billing['country']['iso_code_2'])); $maxVarName = 'max' . ucfirst(strtolower($order->billing['country']['iso_code_2'])); $privacy = ''; $privacyConstant = 'MODULE_PAYMENT_' . strtoupper($this->code) . '_RATEPAY_PRIVACY_URL_' . strtoupper($order->billing['country']['iso_code_2']); if (defined($privacyConstant)) { $privacy = constant($privacyConstant); } $smarty = new Smarty(); /* BEGINN OF DEVICE FINGERPRINT CODE */ if (!rpSession::getRpSessionEntry('RATEPAY_DFP_TOKEN') && rpDb::getRpDfpSId()) { $ratepay_dfp_token = md5($order->info['total'] . microtime()); rpSession::setRpSessionEntry('RATEPAY_DFP_TOKEN', $ratepay_dfp_token); $smarty->assign('RATEPAY_DFP_TOKEN', $ratepay_dfp_token); $smarty->assign('RATEPAY_DFP_SNIPPET_ID', rpDb::getRpDfpSId()); } /* END OF DEVICE FINGERPRINT CODE */ //CS Aenderung des Value von $display['module'] fuer die Ausgabe $display['module'] = $this->public_title; $display['fields'][] = array('title' => '', 'field' => $smarty->fetch(CURRENT_TEMPLATE . '/module/ratepay_rechnung.html')); } return $display; }
/** * Is RatePAY disabled * * @return boolean */ public static function isRatepayAvailable() { return !rpSession::getRpSessionEntry('disabled'); }
/** * This method save's all necessary request and response informations in the database * * @param order $order * @param rpSimpleXmlExtended $request * @param string $orderId * @param SimpleXMLElement $response */ public static function xmlLog($order, $request, $orderId = 'N/A', $response = null) { require_once dirname(__FILE__) . '/../../../../lang/' . rpSession::getLang() . '/modules/payment/' . $order->info['payment_method'] . '.php'; $payment = rpLoader::getRatepayPayment($order->info['payment_method']); if ($payment->logging) { $transactionId = 'N/A'; $subType = 'N/A'; if ($request->head->{'transaction-id'}) { $transactionId = (string) $request->head->{'transaction-id'}; } if ($request->head->operation->attributes()->subtype) { $subType = (string) $request->head->operation->attributes()->subtype; } $operation = (string) $request->head->operation; $responseXml = 'N/A'; if (!empty($response)) { $responseXml = $response->asXML(); $result = (string) $response->head->processing->result; $resultCode = (string) $response->head->processing->result->attributes()->code; $reasonText = (string) $response->head->processing->reason; if ($response->head->{'transaction-id'}) { $transactionId = (string) $response->head->{'transaction-id'}; } } else { $result = "Service unavaible."; $resultCode = "Service unavaible."; } $sql = "INSERT INTO ratepay_log " . "(" . "order_number, " . "transaction_id, " . "payment_method, " . "payment_type, " . "payment_subtype, " . "result, " . "request, " . "response, " . "result_code, " . "reason" . ") " . "VALUES ('" . xtc_db_input($orderId) . "', '" . xtc_db_input($transactionId) . "', '" . xtc_db_input($payment->title) . "', '" . xtc_db_input($operation) . "', '" . xtc_db_input($subType) . "', '" . xtc_db_input($result) . "','" . xtc_db_input(utf8_decode($request->asXML())) . "','" . xtc_db_input($responseXml) . "','" . xtc_db_input($resultCode) . "','" . xtc_db_input($reasonText) . "')"; xtc_db_query($sql); if ($operation == "PAYMENT_CONFIRM" && $transactionId != 'N/A') { $sql = "UPDATE ratepay_log SET order_number = '" . xtc_db_input($orderId) . "' WHERE transaction_id = '" . xtc_db_input($transactionId) . "';"; xtc_db_query($sql); } } }
/** * This method get all needed data and has to be rewritten * Optional - Will only be used, if you want to show the result on another page (include_result.html) * Needs to return an array with the indexes total_amount, amount, interest_amount, service_charge, annual_percentage_rate, monthly_debit_interest, number_of_rates , rate, lastRate * @return array */ public function getData() { return array('total_amount' => rpSession::getRpSessionEntry('ratepay_rate_total_amount'), 'amount' => rpSession::getRpSessionEntry('ratepay_rate_amount'), 'interest_rate' => rpSession::getRpSessionEntry('ratepay_rate_interest_rate'), 'interest_amount' => rpSession::getRpSessionEntry('ratepay_rate_interest_amount'), 'service_charge' => rpSession::getRpSessionEntry('ratepay_rate_service_charge'), 'annual_percentage_rate' => rpSession::getRpSessionEntry('ratepay_rate_annual_percentage_rate'), 'monthly_debit_interest' => rpSession::getRpSessionEntry('ratepay_rate_monthly_debit_interest'), 'number_of_rates' => rpSession::getRpSessionEntry('ratepay_rate_number_of_rates'), 'rate' => rpSession::getRpSessionEntry('ratepay_rate_rate'), 'last_rate' => rpSession::getRpSessionEntry('ratepay_rate_last_rate'), 'payment_firstday' => rpSession::getRpSessionEntry('ratepay_payment_firstday')); }