/** * Call PAYMENT_CHANGE with the subtype full or * part return and updates order and item data */ public static function refundAction() { $post = rpGlobals::getPost(); $orderId = rpGlobals::getPostEntry('order_number'); $order = new order($orderId); $payment = rpLoader::getRatepayPayment($order->info['payment_method']); $transactionId = rpDb::getRatepayOrderDataEntry($orderId, 'transaction_id'); $transactionShortId = rpDb::getRatepayOrderDataEntry($orderId, 'transaction_short_id'); $subType = 'return'; if (rpData::getBasketAmount($order, $orderId, self::getRefundPostData($post), $subType) >= 0) { $data = array('HeadInfo' => rpRequestMapper::getHeadInfoModel($order, $transactionId, $transactionShortId, $orderId, $subType), 'BasketInfo' => rpRequestMapper::getBasketInfoModel($order, $orderId, self::getRefundPostData($post), $subType), 'PaymentInfo' => rpRequestMapper::getPaymentInfoModel($order, $orderId, self::getRefundPostData($post), $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_REFUND_SUCCESS); rpDb::refundRpOrder(self::getRefundPostData($post), $order); rpDb::setRpHistoryEntrys($post, 'PAYMENT_CHANGE', $subType); rpDb::cancelOrRefundShopItems($post, $orderId); rpDb::updateShopOrderTotals($orderId); } else { rpSession::setRpSessionEntry('message_css_class', 'messageStackError'); rpSession::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_REFUND_ERROR); } } else { rpSession::setRpSessionEntry('message_css_class', 'messageStackError'); rpSession::setRpSessionEntry('message', RATEPAY_ORDER_MESSAGE_REFUND_ERROR); } xtc_redirect(xtc_href_link("ratepay_order.php", 'oID=' . $orderId, 'SSL')); }