Ejemplo n.º 1
0
 public function confirmOrder($custom)
 {
     $result = $this->getResult();
     $payment_status = Tools::getValue('payment_status');
     $mc_gross = Tools::getValue('mc_gross');
     $txn_id = Tools::getValue('txn_id');
     $id_order = (int) PayPalOrder::getIdOrderByTransactionId($txn_id);
     if ($id_order != 0) {
         Context::getContext()->cart = new Cart((int) $id_order);
     } elseif (isset($custom['id_cart'])) {
         Context::getContext()->cart = new Cart((int) $custom['id_cart']);
     }
     $address = new Address((int) Context::getContext()->cart->id_address_invoice);
     Context::getContext()->country = new Country((int) $address->id_country);
     Context::getContext()->customer = new Customer((int) Context::getContext()->cart->id_customer);
     Context::getContext()->language = new Language((int) Context::getContext()->cart->id_lang);
     Context::getContext()->currency = new Currency((int) Context::getContext()->cart->id_currency);
     if (isset(Context::getContext()->cart->id_shop)) {
         Context::getContext()->shop = new Shop(Context::getContext()->cart->id_shop);
     }
     if (strcmp(trim($result), "VERIFIED") === false) {
         $details = $this->getIPNTransactionDetails($result);
         if ($id_order != 0) {
             $history = new OrderHistory();
             $history->id_order = (int) $id_order;
             PayPalOrder::updateOrder($id_order, $details);
             $history->changeIdOrderState((int) Configuration::get('PS_OS_ERROR'), $history->id_order);
             $history->addWithemail();
             $history->save();
         }
     } elseif (strcmp(trim($result), "VERIFIED") === 0) {
         $details = $this->getIPNTransactionDetails($result);
         if (version_compare(_PS_VERSION_, '1.5', '<')) {
             $shop = null;
         } else {
             $shop_id = Context::getContext()->shop->id;
             $shop = new Shop($shop_id);
         }
         if ($id_order != 0) {
             $order = new Order((int) $id_order);
             $values = $this->checkPayment($payment_status, $mc_gross, false);
             if ((int) $order->current_state == (int) $values['payment_type']) {
                 return;
             }
             $history = new OrderHistory();
             $history->id_order = (int) $id_order;
             PayPalOrder::updateOrder($id_order, $details);
             $history->changeIdOrderState($values['payment_type'], $history->id_order);
             $history->addWithemail();
             $history->save();
         } else {
             $values = $this->checkPayment($payment_status, $mc_gross, true);
             $customer = new Customer((int) Context::getContext()->cart->id_customer);
             $this->validateOrder(Context::getContext()->cart->id, $values['payment_type'], $values['total_price'], $this->displayName, $values['message'], $details, Context::getContext()->cart->id_currency, false, $customer->secure_key, $shop);
         }
     }
 }
Ejemplo n.º 2
0
* 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
$params = 'cmd=_notify-validate';
foreach ($_POST as $key => $value) {
Ejemplo n.º 3
0
* to license@prestashop.com so we can send you a copy immediately.
*
* DISCLAIMER
*
* 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-2013 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 dirname(__FILE__) . '/paypal_orders.php';
function getIPNTransactionDetails()
{
    $transaction_id = pSQL(Tools::getValue('txn_id'));
    return array('id_invoice' => null, 'id_transaction' => $transaction_id, 'transaction_id' => $transaction_id, 'currency' => pSQL(Tools::getValue('mc_currency')), 'total_paid' => (double) Tools::getValue('mc_gross'), 'shipping' => (double) Tools::getValue('mc_shipping'), 'payment_date' => pSQL(Tools::getValue('payment_date')), 'payment_status' => pSQL(Tools::getValue('payment_status')));
}
if (Tools::getValue('payment_status') !== false) {
    $details = getIPNTransactionDetails();
    $id_order = PayPalOrder::getIdOrderByTransactionId($details['id_transaction']);
    PayPalOrder::updateOrder($id_order, $details);
    $history = new OrderHistory();
    $history->id_order = (int) $id_order;
    $history->changeIdOrderState((int) Configuration::get('PS_OS_PAYMENT'), $history->id_order);
    $history->addWithemail();
    $history->save();
}