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'); } }
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); }
public function action_success() { $this->auto_render = FALSE; $id_order = Core::request('InvId'); //retrieve info for the item in DB $order = new Model_Order(); $order = $order->where('id_order', '=', $id_order)->where('status', '=', Model_Order::STATUS_PAID)->limit(1)->find(); if ($order->loaded()) { //correct payment? if (($result = robokassa::check_result($order, 'success')) !== FALSE) { //redirect him to his ads Alert::set(Alert::SUCCESS, __('Thanks for your payment!')); $this->redirect(Route::url('oc-panel', array('controller' => 'profile', 'action' => 'orders'))); } else { // The card has been declined Alert::set(Alert::INFO, __('Please fill your card details.')); $this->redirect(Route::url('default', array('controller' => 'ad', 'action' => 'checkout', 'id' => $order->id_order))); } } else { Alert::set(Alert::INFO, __('Order could not be loaded')); $this->redirect(Route::url('default')); } }
</li> <?php } ?> <?php if (($securepay = securepay::button($order)) != '') { ?> <li class="text-right"><?php echo $securepay; ?> </li> <?php } ?> <?php if (($robokassa = robokassa::button($order)) != '') { ?> <li class="text-right"><?php echo $robokassa; ?> </li> <?php } ?> <?php if (($paguelofacil = paguelofacil::button($order)) != '') { ?> <li class="text-right"><?php echo $paguelofacil; ?> </li>