Ejemplo n.º 1
0
 /**
  * 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'));
     }
 }
Ejemplo n.º 2
0
 /**
  * Call PAYMENT_CONFIRM request
  * 
  * @global order $order
  * @param string $transactionId
  * @param string $transactionShortId
  * @param int $orderId
  * @return array
  */
 protected function _paymentConfirm($transactionId, $transactionShortId, $orderId)
 {
     global $order;
     $data = array('HeadInfo' => rpRequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId));
     $requestService = new rpRequestService($this->sandbox, $data);
     $result = $requestService->callPaymentConfirm();
     rpDb::xmlLog($order, $requestService->getRequest(), $orderId, $requestService->getResponse());
     return $result;
 }