Example #1
0
 public static function getRatepayPayment($paymentCode)
 {
     if (rpData::isRatepayPayment($paymentCode)) {
         require_once dirname(__FILE__) . '/../../../modules/payment/' . $paymentCode . '.php';
         return new $paymentCode();
     }
     trigger_error('RatePAY payment not found');
 }
 /**
  * Extracts attribute contents FROM a parent tree object
  *
  * @param array  $tree an array containing an array FROM which the
  *                     object data should be extracted
  * @param string $ver  represents the version of the GEDCOM standard
  *                     data is being extracted from
  *
  * @return void
  *
  * @access public
  * @since Method available since Release 0.0.1
  */
 public function parse_tree($tree, $ver)
 {
     if (($i1 = parent::find_tag($tree, Rp_Tags::SOURCE)) !== false) {
         $this->system_id = parent::parse_text($tree[$i1], Rp_Tags::SOURCE);
         if (isset($tree[$i1][1])) {
             $sub2 = $tree[$i1][1];
             if (($i2 = parent::find_tag($sub2, Rp_Tags::VERSION)) !== false) {
                 $this->ver_nbr = parent::parse_text($sub2[$i2], Rp_Tags::VERSION);
             }
             if (($i2 = parent::find_tag($sub2, Rp_Tags::NAME)) !== false) {
                 $this->product_name = parent::parse_text($sub2[$i2], Rp_Tags::NAME);
             }
             $this->corporation->parse_tree($sub2, $ver);
             $this->rp_data->parse_tree($sub2, $ver);
         }
     }
 }
 /**
  * Is called when the checkout_confirmation.php page is called
  */
 public function confirmation()
 {
     $checking = true;
     if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_total_amount'))) {
         $checking = false;
     } else {
         if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_amount'))) {
             $checking = false;
         } else {
             if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_interest_amount'))) {
                 $checking = false;
             } else {
                 if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_service_charge'))) {
                     $checking = false;
                 } else {
                     if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_annual_percentage_rate'))) {
                         $checking = false;
                     } else {
                         if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_monthly_debit_interest'))) {
                             $checking = false;
                         } else {
                             if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_number_of_rates'))) {
                                 $checking = false;
                             } else {
                                 if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_rate'))) {
                                     $checking = false;
                                 } else {
                                     if (rpData::betterEmpty(rpSession::getRpSessionEntry('ratepay_rate_last_rate'))) {
                                         $checking = false;
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     if (!$checking) {
         xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=calculation_error', 'SSL'));
     }
 }
echo rpData::addXmlLineBreak(htmlentities($log['request']));
?>
                                    </textarea>
                                </td>
                            </tr>
                        </table>
                        <hr/>
                        <table border="0" width="100%" cellspacing="0" cellpadding="2">
                            <tr>
                                <th class="pageHeading">Response</th>
                            </tr>
                            <tr>
                                <td style="text-align: center;">
                                    <textarea style="width: 600px; height: 500px;">
                                        <?php 
echo rpData::addXmlLineBreak(htmlentities($log['response']));
?>
                                    </textarea>
                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
            </table>
            <hr/>
            <a href="<?php 
echo xtc_href_link('ratepay_logging.php');
?>
"><b class="button"><?php 
echo RATEPAY_ADMIN_LOG_BACK;
?>
 /**
  * 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'));
     }
 }
 /**
  * Sets the shopping basket in the content tag of the request.
  * 
  * @return rpRequestService
  */
 private function _setRatepayContentBasket()
 {
     $basketInfo = $this->_requestDataObjects['BasketInfo']->getData();
     $shoppingBasket = $this->_request->content->addChild('shopping-basket');
     $shoppingBasket->addAttribute('amount', number_format($basketInfo['amount'], 2, ".", ""));
     $shoppingBasket->addAttribute('currency', strtoupper($basketInfo['currency']));
     $items = $shoppingBasket->addChild('items');
     foreach ($basketInfo['items'] as $itemInfoObject) {
         $itemInfo = $itemInfoObject->getData();
         $item = $items->addCDataChild('item', rpData::removeSpecialChars($itemInfo['articleName']));
         $item->addAttribute('article-number', rpData::removeSpecialChars($itemInfo['articleNumber']));
         $item->addAttribute('unique-article-number', rpData::removeSpecialChars($itemInfo['uniqueArticleNumber']));
         $item->addAttribute('quantity', number_format($itemInfo['quantity'], 0, '.', ''));
         $item->addAttribute('unit-price-gross', number_format(round($itemInfo['unitPriceGross'], 2), 2, ".", ""));
         $item->addAttribute('tax-rate', number_format(round($itemInfo['taxRate'], 2), 0, ".", ""));
     }
     return $this;
 }
    ?>
</td>
                                <td class="dataTableContent"><?php 
    echo $log['payment_subtype'];
    ?>
</td>
                                <td class="dataTableContent"><?php 
    echo $log['result'];
    ?>
</td>
                                <td class="dataTableContent"><?php 
    echo $log['result_code'];
    ?>
</td>
                                <td class="dataTableContent"><?php 
    echo rpData::getRpResult($log['result']);
    ?>
</td>
                                <td class="dataTableContent"><?php 
    echo $log['reason'];
    ?>
</td>
                                <td class="dataTableContent" style="text-align: center;"><a href="<?php 
    echo xtc_href_link('ratepay_log.php', 'id=' . $log['id']);
    ?>
"><b>XML</b></a></td>
                                <td class="dataTableContent"><?php 
    echo $log['date'];
    ?>
</td>
                            </tr>
 public function pre_confirmation_check()
 {
     if (!rpGlobals::hasPostEntry('rp-account-number') || rpData::betterEmpty(rpGlobals::getPostEntry('rp-account-number'))) {
         $this->error['ACCOUNT_NUMBER'] = 'MISSING';
     }
     if (strtoupper(substr(rpGlobals::getPostEntry('rp-account-number'), 0, 2)) !== 'DE') {
         if (!rpGlobals::hasPostEntry('rp-sort-code') || rpData::betterEmpty(rpGlobals::getPostEntry('rp-sort-code'))) {
             $this->error['SORT_CODE'] = 'MISSING';
         }
     }
     if (strtoupper(substr(rpGlobals::getPostEntry('rp-account-number'), 0, 2)) === 'DE') {
         if (strlen(rpGlobals::getPostEntry('rp-account-number')) !== 22) {
             $this->error['ACCOUNT_NUMBER'] = 'DE_WRONG_LENGTH';
         }
         if (!is_numeric(substr(rpGlobals::getPostEntry('rp-account-number'), 2))) {
             $this->error['ACCOUNT_NUMBER'] = 'IBAN_INVALID';
         }
     }
     if (strtoupper(substr(rpGlobals::getPostEntry('rp-account-number'), 0, 2)) === 'AT') {
         if (strlen(rpGlobals::getPostEntry('rp-account-number')) !== 20) {
             $this->error['ACCOUNT_NUMBER'] = 'AT_WRONG_LENGTH';
         }
         if (!is_numeric(substr(rpGlobals::getPostEntry('rp-account-number'), 2))) {
             $this->error['ACCOUNT_NUMBER'] = 'IBAN_INVALID';
         }
     }
     if (is_numeric(substr(rpGlobals::getPostEntry('rp-account-number'), 0, 2))) {
         if (!is_numeric(rpGlobals::getPostEntry('rp-sort-code'))) {
             $this->error['SORT_CODE'] = 'NOT_NUMERIC';
         }
         if (strlen(rpGlobals::getPostEntry('rp-sort-code')) !== 8) {
             $this->error['SORT_CODE'] = 'WRONG_LENGTH';
         }
         if (!is_numeric(rpGlobals::getPostEntry('rp-account-number'))) {
             $this->error['ACCOUNT_NUMBER'] = 'KONTO_NR_NOT_NUMERIC';
         }
     }
     if (!is_numeric(substr(rpGlobals::getPostEntry('rp-account-number'), 0, 2))) {
         if (is_numeric(rpGlobals::getPostEntry('rp-sort-code')) && !rpData::betterEmpty(rpGlobals::getPostEntry('rp-sort-code'))) {
             $this->error['SORT_CODE'] = 'IBAN_AND_BLZ_PROVIDED';
         }
     }
     if (!rpGlobals::hasPostEntry('rp-account-holder') || rpData::betterEmpty(rpGlobals::getPostEntry('rp-account-holder'))) {
         $this->error['ACCOUNT_HOLDER'] = 'MISSING';
     }
     if (!rpGlobals::hasPostEntry('rp-bank-name') || rpData::betterEmpty(rpGlobals::getPostEntry('rp-bank-name'))) {
         $this->error['BANK_NAME'] = 'MISSING';
     }
     if (empty($this->error)) {
         $this->setBankData($_POST);
     }
     parent::pre_confirmation_check();
 }
                                                        <th class="dataTableHeadingContent"><?php 
    echo RATEPAY_ORDER_RATEPAY_ADMIN_DELIVERED;
    ?>
</th>
                                                        <th class="dataTableHeadingContent"><?php 
    echo RATEPAY_ORDER_RATEPAY_ADMIN_RETURNED;
    ?>
</th>
                                                    </tr>
                                                    <?php 
    foreach ($returnItems as $item) {
        ?>
                                                    <tr class="dataTableRow">
                                                        <td class="dataTableContent">
                                                            <?php 
        $qty = rpData::getAvailableItemQtyToRefund($item);
        ?>
                                                            <input <?php 
        if ($qty <= 0) {
            echo 'disabled="disabled"';
        }
        ?>
 type="text" name="items[<?php 
        echo $item['id'];
        ?>
]" value="<?php 
        echo $qty;
        ?>
" onKeyUp="RpOrder.check(this, <?php 
        echo $qty;
        ?>
 /**
  * Is called when the user clicks the "process button" but before the order is saved
  * here we send the PAYMENT_INIT and PAYMENT_REQUEST call to RatePAY in case of an 
  * we redirect the user to the checkout_payment.php with an error message
  */
 public function before_process()
 {
     global $order;
     $result = $this->_paymentInit();
     if (!array_key_exists('error', $result) && array_key_exists('transactionId', $result)) {
         rpSession::setRpSessionEntry('transactionId', $result['transactionId']);
         rpSession::setRpSessionEntry('transactionShortId', $result['transactionShortId']);
         $result = $this->_paymentRequest($result['transactionId'], $result['transactionShortId']);
         if (array_key_exists('error', $result) && !array_key_exists('transactionId', $result)) {
             rpSession::cleanRpSession();
             if ($this->sandbox !== true) {
                 rpData::disableRatepay();
             }
             $error = urlencode(constant(strtoupper($this->code) . '_ERROR'));
             xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $error, 'SSL'));
         } else {
             rpSession::setRpSessionEntry('customers_country_code', $order->customer['country']['iso_code_2']);
             rpSession::setRpSessionEntry('descriptor', $result['descriptor']);
             rpSession::setRpSessionEntry('rpOrder', clone $order);
         }
     } else {
         if ($this->sandbox !== true) {
             rpData::disableRatepay();
         }
         $error = urlencode(constant(strtoupper($this->code) . '_ERROR_GATEWAY'));
         xtc_redirect(xtc_href_link(FILENAME_CHECKOUT_PAYMENT, 'error_message=' . $error, 'SSL'));
     }
 }
 /**
  * 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;
 }
Example #12
0
 /**
  * Set all order items to the ratepay order
  *
  * @param order $order
  * @param int $orderId
  * @param string $payment
  */
 public static function setRpOrderItems(order $order, $orderId, $payment)
 {
     foreach ($order->products as $product) {
         self::setRpOrderItem(rpData::getItemData($product), $orderId, $payment);
     }
     foreach (rpData::getDiscounts() as $discountData) {
         $discount = rpData::getDiscountData($discountData);
         if (!empty($discount)) {
             self::setRpOrderItem($discount, $orderId, $payment);
         }
     }
     $shipping = rpData::getShippingData($order);
     if (!empty($shipping)) {
         self::setRpOrderItem($shipping, $orderId, $payment);
     }
 }