Beispiel #1
0
}
if (!($amount = (double) Tools::getValue('mc_gross') || $amount != $order->total_paid)) {
    die($paypal->l('Incorrect amount'));
}
if (!($status = (string) Tools::getValue('payment_status'))) {
    die($paypal->l('Incorrect order status'));
}
// Getting params
$params = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
    $params .= '&' . $key . '=' . urlencode(stripslashes($value));
}
// Checking params by asking PayPal
include _PS_MODULE_DIR_ . 'paypal/api/paypal_lib.php';
$paypalAPI = new PaypalLib();
$result = $paypalAPI->makeSimpleCall($paypal->getAPIURL(), $paypal->getAPIScript(), $params);
if (!$result || Tools::strlen($result) < 8 || !($status = substr($result, -8)) || $status != 'VERIFIED') {
    die($paypal->l('Cannot verify PayPal order'));
}
// Getting order status
switch ($status) {
    case 'Completed':
        $id_order_state = Configuration::get('PS_OS_PAYMENT');
        break;
    case 'Pending':
        $id_order_state = Configuration::get('PS_OS_PAYPAL');
        break;
    default:
        $id_order_state = Configuration::get('PS_OS_ERROR');
}
if ($order->getCurrentState() == $id_order_state) {