Exemplo n.º 1
0
 public function initContent()
 {
     parent::initContent();
     $ordernumber = Tools::getValue('InvId');
     $this->context->smarty->assign('ordernumber', $ordernumber);
     if (Configuration::get('robokassa_postvalidate')) {
         if (!$ordernumber) {
             robokassa::validateAnsver($this->module->l('Cart number is not set'));
         }
         $cart = new Cart((int) $ordernumber);
         if (!Validate::isLoadedObject($cart)) {
             robokassa::validateAnsver($this->module->l('Cart does not exist'));
         }
         if (!($ordernumber = Order::getOrderByCartId($cart->id))) {
             $this->setTemplate('waitingPayment.tpl');
         }
     }
     if (!$ordernumber) {
         robokassa::validateAnsver($this->module->l('Order number is not set'));
     }
     $order = new Order((int) $ordernumber);
     if (!Validate::isLoadedObject($order)) {
         robokassa::validateAnsver($this->module->l('Order does not exist'));
     }
     $customer = new Customer((int) $order->id_customer);
     if ($customer->id != $this->context->cookie->id_customer) {
         robokassa::validateAnsver($this->module->l('You are not logged in'));
     }
     if ($order->hasBeenPaid()) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order-confirmation.php?key=' . $customer->secure_key . '&id_cart=' . (int) $order->id_cart . '&id_module=' . (int) $this->module->id . '&id_order=' . (int) $order->id);
     } else {
         $this->setTemplate('waitingPayment.tpl');
     }
 }
Exemplo n.º 2
0
 public function postProcess()
 {
     parent::postProcess();
     //ИД заказа
     $ordernumber = Tools::getValue('InvId');
     //Сумма заказа
     $amount = Tools::getValue('OutSum');
     $signature = md5($amount . ':' . $ordernumber . ':' . Configuration::get('robokassa_password2'));
     //Проверка подписи
     if (strtoupper($signature) != Tools::getValue('SignatureValue')) {
         robokassa::validateAnsver($this->module->l('Invalid signature'));
     }
     if (Configuration::get('robokassa_postvalidate')) {
         $cart = new Cart((int) $ordernumber);
         //Проверка существования заказа
         if (!Validate::isLoadedObject($cart)) {
             robokassa::validateAnsver($this->module->l('Cart does not exist'));
         }
         $total_to_pay = $cart->getOrderTotal(true, Cart::BOTH);
         $currency_rub = new Currency(Currency::getIdByIsoCode('RUB'));
         if ($cart->id_currency != $currency_rub->id) {
             $currency = new Currency($cart->id_currency);
             $total_to_pay = $total_to_pay / $currency->conversion_rate * $currency_rub->conversion_rate;
         }
         $total_to_pay = number_format($total_to_pay, 2, '.', '');
         //Проверка суммы заказа
         if ($amount != $total_to_pay) {
             robokassa::validateAnsver($this->module->l('Incorrect payment summ'));
         }
         $this->module->validateOrder((int) $cart->id, Configuration::get('PS_OS_PAYMENT'), $cart->getOrderTotal(true, Cart::BOTH), $this->module->displayName, NULL, array(), NULL, false, $cart->secure_key);
     } else {
         $order = new Order((int) $ordernumber);
         //Проверка существования заказа
         if (!Validate::isLoadedObject($order)) {
             robokassa::validateAnsver($this->module->l('Order does not exist'));
         }
         $total_to_pay = $order->total_paid;
         $currency_rub = new Currency(Currency::getIdByIsoCode('RUB'));
         if ($order->id_currency != $currency_rub->id) {
             $currency = new Currency($order->id_currency);
             $total_to_pay = $total_to_pay / $currency->conversion_rate * $currency_rub->conversion_rate;
         }
         $total_to_pay = number_format($total_to_pay, 2, '.', '');
         //Проверка суммы заказа
         if ($amount != $total_to_pay) {
             robokassa::validateAnsver($this->module->l('Incorrect payment summ'));
         }
         //Меняем статус заказа
         $history = new OrderHistory();
         $history->id_order = $ordernumber;
         $history->changeIdOrderState(Configuration::get('PS_OS_PAYMENT'), $ordernumber);
         $history->addWithemail(true);
     }
     die('OK' . $ordernumber);
 }