/**
  * Call PAYMENT_CHANGE with the subtype credit
  * and add a credit item to the order
  */
 public static function creditAction()
 {
     $orderId = Globals::getPostEntry('order_number');
     $order = new order($orderId);
     $payment = Loader::getRatepayPayment($order->info['payment_method']);
     $transactionId = Db::getRatepayOrderDataEntry($orderId, 'transaction_id');
     $transactionShortId = Db::getRatepayOrderDataEntry($orderId, 'transaction_short_id');
     $data = array('HeadInfo' => RequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId, 'credit'), 'BasketInfo' => RequestMapper::getBasketInfoModel($order, $orderId, Globals::getPost()), 'CustomerInfo' => RequestMapper::getCustomerInfoModel($order, $orderId), 'PaymentInfo' => RequestMapper::getPaymentInfoModel($order, $orderId));
     $requestService = new RequestService($payment->sandbox, $data);
     $result = $requestService->callPaymentChange();
     Db::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse());
     if (!array_key_exists('error', $result)) {
         Session::setRpSessionEntry('message_css_class', 'messageStackSuccess');
         Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_SUCCESS);
         Db::setRpCreditItem(Globals::getPost());
         Db::setRpHistoryEntry($orderId, Data::getCreditItem(Globals::getPost()), 'PAYMENT_CHANGE', 'credit');
         Db::addCreditToShop($orderId, Globals::getPost());
         Db::updateShopOrderTotals($orderId);
     } else {
         Session::setRpSessionEntry('message_css_class', 'messageStackError');
         Session::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_CREDIT_ERROR);
     }
     tep_redirect(tep_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL'));
 }
 public function pre_confirmation_check()
 {
     if ($this->_isBankAccountNeeded()) {
         $accountOwner = trim(Globals::getPostEntry('ratepay_lastschrift_bankaccountowner'));
         $accountNumber = strtoupper(trim(Globals::getPostEntry('ratepay_lastschrift_bankaccountnumber')));
         $bankCode = strtoupper(trim(Globals::getPostEntry('ratepay_lastschrift_bankcode')));
         $bankName = trim(Globals::getPostEntry('ratepay_lastschrift_bankname'));
         $conditions = Globals::getPostEntry('ratepay_lastschrift_conditions');
         if ($this->_checkBankAccountOwner($accountOwner)) {
             $bankAccount['owner'] = $accountOwner;
         } else {
             $this->error['ACCOUNTOWNER'] = 'MISSING';
         }
         switch ($this->_checkBankAccountNumber($accountNumber)) {
             case 'IBAN':
                 $bankAccount['iban'] = $accountNumber;
                 break;
             case 'ACCNR':
                 $bankAccount['bank-account-number'] = $accountNumber;
                 break;
             case 'MISSING':
                 $this->error['ACCOUNTNUMBER'] = 'MISSING';
                 break;
             case 'WRONG_COUNTRY':
                 $this->error['ACCOUNTNUMBER'] = 'WRONG_COUNTRY';
                 break;
             case 'INVALID':
                 $this->error['ACCOUNTNUMBER'] = 'INVALID';
                 break;
         }
         switch ($this->_checkBankCode($bankCode)) {
             case 'BIC':
                 $bankAccount['bic-swift'] = $bankCode;
                 break;
             case 'BLZ':
                 $bankAccount['bank-code'] = $bankCode;
                 break;
             case 'MISSING':
                 if (!$bankAccount['iban'] || $this->country != 'DE') {
                     $this->error['BANKCODE'] = 'MISSING';
                 }
                 break;
             case 'INVALID':
                 $this->error['BANKCODE'] = 'INVALID';
                 break;
         }
         if ($this->_checkBankName($bankName)) {
             $bankAccount['bank-name'] = $bankName;
         } else {
             $this->error['BANKNAME'] = 'MISSING';
         }
         if ($bankAccount['bank-account-number'] && $bankAccount['bic-swift'] || $bankAccount['iban'] && $bankAccount['bank-code']) {
             $this->error['BANKACCOUNTS'] = 'INVALID';
         }
         if ($bankAccount) {
             $this->setBankData($bankAccount);
         }
         if (!$this->_checkBankConditions($conditions)) {
             $this->error['CONDITIONS'] = 'MISSING';
         }
     }
     parent::pre_confirmation_check();
 }
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License, version 2, as
 * published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * @category  PayIntelligent
 * @package   ratepay
 * @copyright (C) 2012 PayIntelligent GmbH  <http://www.payintelligent.de/>
 * @license   GPLv2
 */
/**
 * Delete logging script
 */
require_once 'includes/application_top.php';
require_once '../includes/classes/ratepay/helpers/Data.php';
require_once '../includes/classes/ratepay/helpers/Globals.php';
if (Globals::hasPostEntry('submit')) {
    $days = Globals::getPostEntry('days');
    if (preg_match("/^[0-9]{1,2}\$/", $days)) {
        if ($days == 0) {
            tep_db_query("delete from ratepay_log");
        } else {
            tep_db_query("DELETE FROM ratepay_log WHERE TO_DAYS(now()) - TO_DAYS(date) > " . (int) $days);
        }
    }
}
tep_redirect(tep_href_link('ratepay_logging.php', 'success=1', 'SSL'));
 /**
  * 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);
     }
 }