Example #1
0
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
* versions in the future. If you wish to customize PrestaShop for your
* needs please refer to http://www.prestashop.com for more information.
*
*  @author PrestaShop SA <*****@*****.**>
*  @copyright  2007-2012 PrestaShop SA
*  @license    http://opensource.org/licenses/afl-3.0.php  Academic Free License (AFL 3.0)
*  International Registered Trademark & Property of PrestaShop SA
*/
include_once dirname(__FILE__) . '/../../config/config.inc.php';
include_once dirname(__FILE__) . '/../../init.php';
include_once _PS_MODULE_DIR_ . 'paypal/paypal.php';
$paypal = new Paypal();
$paypal_order = new PayPalOrder();
if (!($transaction_id = Tools::getValue('txn_id'))) {
    die($paypal->l('No transaction id'));
}
if (!($id_order = $paypal_order->getIdOrderByTransactionId($transaction_id))) {
    die($paypal->l('No order'));
}
$order = new Order((int) $id_order);
if (!Validate::isLoadedObject($order) || !$order->id) {
    die($paypal->l('Invalid order'));
}
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
Example #2
0
            $this->context->smarty->assign('errors', array($this->paypal->l('Payment error')));
        }
        echo $this->paypal->fetchTemplate('/views/templates/front/', 'order-confirmation');
    }
}
if (Tools::getValue('id_module') && Tools::getValue('key') && Tools::getValue('id_cart') && Tools::getValue('id_order')) {
    if (_PS_VERSION_ < '1.5') {
        new PayPalExpressCheckoutSubmit();
    }
} elseif (Tools::getValue('get_qty')) {
    /* Ajax response */
    $id_product = (int) Tools::getValue('id_product');
    $id_product_attribute = (int) Tools::getValue('id_product_attribute');
    if (Product::getQuantity((int) $id_product, (int) $id_product_attribute) <= 0) {
        $paypal = new Paypal();
        die($paypal->l('This product is no longer in stock with those attributes but is available with others'));
    }
    die(true);
} else {
    $request_type = Tools::getValue('express_checkout');
    $ppec = new PaypalExpressCheckout($request_type);
    if ($request_type && $ppec->type) {
        $id_product = (int) Tools::getValue('id_product');
        $id_product_attribute = (int) Tools::getValue('id_p_attr');
        $product_quantity = (int) Tools::getValue('quantity');
        if ($id_product > 0 && $id_product_attribute !== false && $product_quantity > 0) {
            // Create new Cart to avoid any refresh or other bad manipulations
            $ppec->context->cart = new Cart();
            $ppec->context->cart->id_currency = (int) $ppec->context->currency->id;
            $ppec->context->cart->id_lang = (int) $ppec->context->language->id;
            $secure_key = isset($ppec->context->customer) ? $ppec->context->customer->secure_key : '';
Example #3
0
$params = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
    $params .= '&' . $key . '=' . urlencode(stripslashes($value));
}
// PayPal Server
$paypalServer = 'www.' . (Configuration::get('PAYPAL_SANDBOX') ? 'sandbox.' : '') . 'paypal.com';
// Getting PayPal data...
if (function_exists('curl_exec')) {
    // curl ready
    $ch = curl_init('https://' . $paypalServer . '/cgi-bin/webscr');
    // If the above fails, then try the url with a trailing slash (fixes problems on some servers)
    if (!$ch) {
        $ch = curl_init('https://' . $paypalServer . '/cgi-bin/webscr/');
    }
    if (!$ch) {
        $errors .= $paypal->l('Problem connecting to the PayPal server.');
        $errors .= ' ';
        $errors .= $paypal->l('Connection using cURL failed');
    } else {
        curl_setopt($ch, CURLOPT_POST, true);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_TIMEOUT, 30);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
        $result = curl_exec($ch);
        if (strtoupper($result) != 'VERIFIED') {
            $errors .= $paypal->l('Verification failure (using cURL). Returned: ') . $result . ' cURL error:' . curl_error($ch);
        }
        curl_close($ch);
    }