Example #1
0
            }
        }
    }
    exit('Error when continuing order');
} elseif (empty($_GET['token'])) {
    exit('Access denied');
}
$response = $handler->request(array('METHOD' => 'GetExpressCheckoutDetails', 'TOKEN' => $_GET['token']));
$context = '';
$params = array();
if (!is_array($response)) {
    $modx->log(modX::LOG_LEVEL_ERROR, '[miniShop2] Error on receive details of PayPal operation: ' . $response . '; ' . print_r($_GET, 1));
} else {
    if (!empty($response['PAYMENTREQUEST_0_INVNUM'])) {
        if ($order = $modx->getObject('msOrder', $response['PAYMENTREQUEST_0_INVNUM'])) {
            $handler->receive($order, $response);
            $context = $order->get('context');
            $params['msorder'] = $order->get('id');
        } else {
            $modx->log(modX::LOG_LEVEL_ERROR, '[miniShop2] Could not retrieve order with id ' . $response['PAYMENTREQUEST_0_INVNUM']);
        }
    } else {
        $modx->log(modX::LOG_LEVEL_ERROR, '[miniShop2] Error on receive details of PayPal operation: ' . print_r($response, 1) . '; ' . print_r($_GET, 1));
    }
}
$success = $cancel = $modx->getOption('site_url');
if ($id = $modx->getOption('ms2_payment_paypal_success_id', null, 0)) {
    $success = $modx->makeUrl($id, $context, $params, 'full');
}
if ($id = $modx->getOption('ms2_payment_paypal_cancel_id', null, 0)) {
    $cancel = $modx->makeUrl($id, $context, $params, 'full');