コード例 #1
0
ファイル: submit.php プロジェクト: ventsiwad/presta_addons
 public function initContent()
 {
     parent::initContent();
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     $this->id_module = (int) Tools::getValue('id_module');
     $this->id_order = (int) Tools::getValue('id_order');
     $order = new Order($this->id_order);
     $order_state = new OrderState($order->current_state);
     $paypal_order = PayPalOrder::getOrderById($this->id_order);
     if ($order_state->template[$this->context->language->id] == 'payment_error') {
         $this->context->smarty->assign(array('message' => $order_state->name[$this->context->language->id], 'logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => Tools::displayPrice($paypal_order['total_paid'], $this->context->currency)));
         return $this->setTemplate('error.tpl');
     }
     $order_currency = new Currency((int) $order->id_currency);
     $display_currency = new Currency((int) $this->context->currency->id);
     $price = Tools::convertPriceFull($paypal_order['total_paid'], $order_currency, $display_currency);
     $this->context->smarty->assign(array('is_guest' => $this->context->customer->is_guest || $this->context->customer->id == false, 'order' => $paypal_order, 'price' => Tools::displayPrice($price, $this->context->currency->id), 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()));
     if ($this->context->customer->is_guest || $this->context->customer->id == false) {
         $this->context->smarty->assign(array('id_order' => (int) $this->id_order, 'id_order_formatted' => sprintf('#%06d', (int) $this->id_order), 'order_reference' => $order->reference));
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     if ($this->context->getMobileDevice() == true) {
         $this->setTemplate('order-confirmation-mobile.tpl');
     } else {
         $this->setTemplate('order-confirmation.tpl');
     }
 }
コード例 #2
0
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = new Order($id_order);
     $paypal_order = PayPalOrder::getOrderById($id_order);
     if (defined("PAYPAL_FORCE_CURRENCY")) {
         $currency = new Currency((int) $this->context->currency->id);
         $paycurrency = new Currency(PAYPAL_FORCE_CURRENCY);
         $currency_decimals = $paycurrency->decimals;
         $paypal_order['total_paid'] = $paypal_order['total_paid'] / $currency->conversion_rate * $paycurrency->conversion_rate;
     }
     $price = Tools::displayPrice($paypal_order['total_paid'], $this->context->currency);
     $order_state = new OrderState($id_order);
     if ($order_state) {
         $order_state_message = $order_state->template[$this->context->language->id];
     }
     if (!$order || !$order_state || isset($order_state_message) && $order_state_message == 'payment_error') {
         $this->context->smarty->assign(array('logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => $price));
         if (isset($order_state_message) && $order_state_message) {
             $this->context->smarty->assign('message', $order_state_message);
         }
         $template = 'error.tpl';
     } else {
         $this->context->smarty->assign(array('order' => $paypal_order, 'price' => $price));
         if (version_compare(_PS_VERSION_, '1.5', '>')) {
             $this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($paypal_order['id_order'])));
         }
         $template = 'order-confirmation.tpl';
     }
     $this->context->smarty->assign('use_mobile', (bool) $this->paypal->useMobile());
     echo $this->paypal->fetchTemplate($template);
 }
コード例 #3
0
ファイル: submit.php プロジェクト: ventsiwad/presta_addons
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($id_order);
     $price = Tools::displayPrice($order['total_paid'], $this->context->currency);
     $this->context->smarty->assign(array('order' => $order, 'price' => $price));
     echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
 }
コード例 #4
0
 public function displayContent()
 {
     $order = PayPalOrder::getOrderById((int) Tools::getValue('id_order'));
     $this->context->smarty->assign(array('order' => $order, 'price' => Tools::displayPrice($order['total_paid'], $this->context->currency), 'use_mobile' => $this->context->getMobileDevice()));
     if (!$order) {
         $this->context->smarty->assign('errors', array($this->paypal->l('Payment error')));
     }
     echo $this->paypal->fetchTemplate('/views/templates/front/', 'order-confirmation');
 }
コード例 #5
0
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($id_order);
     $price = Tools::displayPrice($order['total_paid'], $this->context->currency);
     $this->context->smarty->assign(array('order' => $order, 'price' => $price));
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($id_order)));
     }
     echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
 }
コード例 #6
0
 public function initContent()
 {
     parent::initContent();
     $this->paypal = new PayPal();
     $this->context = Context::getContext();
     $this->id_module = (int) Tools::getValue('id_module');
     $this->id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($this->id_order);
     $this->context->smarty->assign(array('is_guest' => $this->context->customer->is_guest, 'order' => $order, 'price' => Tools::displayPrice($order['total_paid'], $this->context->currency), 'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(), 'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()));
     if ($this->context->customer->is_guest) {
         $this->context->smarty->assign(array('id_order' => (int) $this->order->id_order, 'id_order_formatted' => sprintf('#%06d', (int) $this->order->id_order)));
         /* If guest we clear the cookie for security reason */
         $this->context->customer->mylogout();
     }
     $this->setTemplate('order-confirmation.tpl');
 }
コード例 #7
0
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = PayPalOrder::getOrderById($id_order);
     if (defined("PAYPAL_FORCE_CURRENCY")) {
         $currency = new Currency((int) $this->context->currency->id);
         $paycurrency = new Currency(PAYPAL_FORCE_CURRENCY);
         $currency_decimals = $paycurrency->decimals;
         $order['total_paid'] = $order['total_paid'] / $currency->conversion_rate * $paycurrency->conversion_rate;
     }
     $price = Tools::displayPrice($order['total_paid'], $this->context->currency);
     $this->context->smarty->assign(array('order' => $order, 'price' => $price));
     if (version_compare(_PS_VERSION_, '1.5', '>')) {
         $this->context->smarty->assign(array('reference_order' => Order::getUniqReferenceOf($id_order)));
     }
     echo $this->context->smarty->fetch(_PS_MODULE_DIR_ . '/paypal/views/templates/front/order-confirmation.tpl');
 }
コード例 #8
0
ファイル: submit.php プロジェクト: Evil1991/PrestaShop-1.4
 public function displayContent()
 {
     $id_order = (int) Tools::getValue('id_order');
     $order = new Order($id_order);
     $paypal_order = PayPalOrder::getOrderById($id_order);
     $price = Tools::displayPrice($paypal_order['total_paid'], $this->context->currency);
     $order_state = new OrderState($id_order);
     if ($order_state) {
         $order_state_message = $order_state->template[$this->context->language->id];
     }
     if (!$order || !$order_state || isset($order_state_message) && $order_state_message == 'payment_error') {
         $this->context->smarty->assign(array('logs' => array($this->paypal->l('An error occurred while processing payment.')), 'order' => $paypal_order, 'price' => $price));
         if (isset($order_state_message) && $order_state_message) {
             $this->context->smarty->assign('message', $order_state_message);
         }
         $template = 'error.tpl';
     } else {
         $this->context->smarty->assign(array('order' => $paypal_order, 'price' => $price));
         $template = 'order-confirmation.tpl';
     }
     $this->context->smarty->assign('use_mobile', (bool) $this->paypal->useMobile());
     echo $this->paypal->fetchTemplate($template);
 }
コード例 #9
0
ファイル: paypal.php プロジェクト: ramsam5/paypal
    private function _updatePaymentStatusOfOrder($id_order)
    {
        if (!(bool) $id_order || !$this->isPayPalAPIAvailable()) {
            return false;
        }
        $paypal_order = PayPalOrder::getOrderById((int) $id_order);
        if (!$paypal_order) {
            return false;
        }
        $paypal_lib = new PaypalLib();
        $response = $paypal_lib->makeCall($this->getAPIURL(), $this->getAPIScript(), 'GetTransactionDetails', '&' . http_build_query(array('TRANSACTIONID' => $paypal_order['id_transaction']), '', '&'));
        if (array_key_exists('ACK', $response)) {
            if ($response['ACK'] == 'Success' && isset($response['PAYMENTSTATUS'])) {
                $history = new OrderHistory();
                $history->id_order = (int) $id_order;
                if ($response['PAYMENTSTATUS'] == 'Completed') {
                    $history->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), (int) $id_order);
                } elseif ($response['PAYMENTSTATUS'] == 'Pending' && $response['PENDINGREASON'] == 'authorization') {
                    $history->changeIdOrderState((int) Configuration::get('PAYPAL_OS_AUTHORIZATION'), (int) $id_order);
                } elseif ($response['PAYMENTSTATUS'] == 'Reversed') {
                    $history->changeIdOrderState(Configuration::get('PS_OS_ERROR'), (int) $id_order);
                }
                $history->addWithemail();
                if (!Db::getInstance()->Execute('
				UPDATE `' . _DB_PREFIX_ . 'paypal_order`
				SET `payment_status` = \'' . pSQL($response['PAYMENTSTATUS']) . ($response['PENDINGREASON'] == 'authorization' ? '_authorization' : '') . '\'
				WHERE `id_order` = ' . (int) $id_order)) {
                    die(Tools::displayError('Error when updating PayPal database'));
                }
            }
            $message = $this->l('Verification status :') . '<br>';
            $this->formatMessage($response, $message);
            $this->_addNewPrivateMessage((int) $id_order, $message);
            return $response;
        }
        return false;
    }