<?php

use Mtc\Shop\Order\Protx;

$path = '../../../';
require_once $path . 'core/includes/header.inc.php';
require SITE_PATH . '/shop/checkout/server/function.sagepay.php';

$order = new \Order(request()->input('order_id'));
if ($order->hasOutstandingDeferredPayment()) {
    $result = Protx::capturePayment(request()->input('order_id'), request()->input('transaction_id'), $strReleaseURL);
    if ($result['success']) {
        $_SESSION['message'] = $result['message'];
    } else {
        $_SESSION['error'] = $result['message'];
    }
}

header('Location: ' . back()->getTargetUrl());
exit;
