Esempio n. 1
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     $oplata = new Oplata();
     if ($_POST['order_status'] == OplataCls::ORDER_DECLINED) {
         $this->errors[] = Tools::displayError('Order declined');
     }
     $settings = array('merchant_id' => $oplata->getOption('merchant'), 'secret_key' => $oplata->getOption('secret_key'));
     $isPaymentValid = OplataCls::isPaymentValid($settings, $_POST);
     if ($isPaymentValid !== true) {
         $this->errors[] = Tools::displayError($isPaymentValid);
     }
     $cart = $this->context->cart;
     if ($cart->id_customer == 0 || $cart->id_address_delivery == 0 || $cart->id_address_invoice == 0 || !$this->module->active) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     $customer = new Customer($cart->id_customer);
     if (!Validate::isLoadedObject($customer)) {
         Tools::redirect('index.php?controller=order&step=1');
     }
     if (empty($this->errors)) {
         list($orderId, ) = explode(OplataCls::ORDER_SEPARATOR, $_POST['order_id']);
         $history = new OrderHistory();
         $history->id_order = $orderId;
         $history->changeIdOrderState((int) Configuration::get('PS_OS_PAYMENT'), $orderId);
         $history->addWithemail(true, array('order_name' => $orderId));
         Tools::redirect('index.php?controller=order-confirmation&id_cart=' . $cart->id . '&id_module=' . $this->module->id . '&id_order=' . $this->module->currentOrder . '&key=' . $customer->secure_key);
     }
 }
Esempio n. 2
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     global $cookie, $link;
     $language = Language::getIsoById(intval($cookie->id_lang));
     $language = !in_array($language, array('ua', 'en', 'ru')) ? 'ru' : $language;
     $payCurrency = Context::getContext()->currency;
     $cart = $this->context->cart;
     $oplata = new Oplata();
     $total = $cart->getOrderTotal();
     $oplata->validateOrder(intval($cart->id), _PS_OS_PREPARATION_, $total, $oplata->displayName);
     $fields = array('order_id' => $oplata->currentOrder . OplataCls::ORDER_SEPARATOR . time(), 'merchant_id' => $oplata->getOption('merchant'), 'order_desc' => 'Order description', 'amount' => round($total * 100), 'currency' => $payCurrency->iso_code, 'server_callback_url' => $link->getModuleLink('oplata', 'callback'), 'response_url' => $link->getModuleLink('oplata', 'result'), 'lang' => strtoupper($language), 'sender_email' => $this->context->customer->email);
     $fields['signature'] = OplataCls::getSignature($fields, $oplata->getOption('secret_key'));
     $fields['oplata_url'] = OplataCls::URL;
     $this->context->smarty->assign($fields);
     $this->setTemplate('redirect.tpl');
 }
Esempio n. 3
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     global $cart, $cookie, $smarty;
     //        $cart->id = $_GET['id_cart'];
     $customer = new Customer((int) $cart->id_customer);
     $language = Language::getIsoById(intval($cookie->id_lang));
     $language = !in_array($language, array('ua', 'en', 'ru')) ? 'ru' : $language;
     $currency = new Currency($cookie->id_currency);
     $oplata = new Oplata();
     $total = $cart->getOrderTotal();
     $callback = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/oplata/callback.php';
     $result = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/oplata/result.php';
     $oplata->validateOrder(intval($cart->id), _PS_OS_PREPARATION_, $total, $oplata->displayName);
     $fields = array('order_id' => $oplata->currentOrder . OplataCls::ORDER_SEPARATOR . time(), 'merchant_id' => $oplata->getOption('merchant'), 'order_desc' => 'Order description', 'amount' => round($total * 100), 'currency' => $currency->iso_code, 'server_callback_url' => $callback, 'response_url' => $result, 'lang' => strtoupper($language), 'sender_email' => $customer->email, 'delayed' => 'N');
     $fields['signature'] = OplataCls::getSignature($fields, $oplata->getOption('secret_key'));
     $fields['oplata_url'] = OplataCls::URL;
     $smarty->assign($fields);
     echo $this->display('redirect.tpl');
 }
Esempio n. 4
0
 /**
  * @see FrontController::postProcess()
  */
 public function postProcess()
 {
     try {
         if ($_POST['order_status'] == OplataCls::ORDER_DECLINED) {
             exit('Order declined');
         }
         $oplata = new Oplata();
         $settings = array('merchant_id' => $oplata->getOption('merchant'), 'secret_key' => $oplata->getOption('secret_key'));
         $isPaymentValid = OplataCls::isPaymentValid($settings, $_POST);
         if ($isPaymentValid !== true) {
             exit($isPaymentValid);
         }
         list($orderId, ) = explode(OplataCls::ORDER_SEPARATOR, $_POST['order_id']);
         $history = new OrderHistory();
         $history->id_order = $orderId;
         $history->changeIdOrderState((int) Configuration::get('PS_OS_PAYMENT'), $orderId);
         $history->addWithemail(true, array('order_name' => $orderId));
         exit('OK');
     } catch (Exception $e) {
         exit(get_class($e) . ': ' . $e->getMessage());
     }
 }
Esempio n. 5
0
 public function postProcess()
 {
     list($orderId, ) = explode(OplataCls::ORDER_SEPARATOR, $_POST['order_id']);
     $this->_order = new Order(intval($orderId));
     $this->_customer = new Customer($this->_order->id_customer);
     if ($_POST['order_status'] == OplataCls::ORDER_DECLINED) {
         $this->showError(Tools::displayError('Order declined'));
     }
     $settings = array('merchant_id' => $this->getOption('merchant'), 'secret_key' => $this->getOption('secret_key'));
     $isPaymentValid = OplataCls::isPaymentValid($settings, $_POST);
     if ($isPaymentValid !== true) {
         $this->showError(Tools::displayError($isPaymentValid));
     }
     if (!Validate::isLoadedObject($this->_customer)) {
         Tools::redirectLink(__PS_BASE_URI__ . 'order.php?step=1');
     }
     $history = new OrderHistory();
     $history->id_order = $orderId;
     $id_order_state = _PS_OS_PAYMENT_;
     $history->changeIdOrderState(intval($id_order_state), intval($orderId));
     $history->addWithemail(true, "");
     // redirect to success
     Tools::redirectLink(__PS_BASE_URI__ . 'modules/oplata/result-success.php');
 }