Exemple #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);
     }
 }
Exemple #2
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());
     }
 }
Exemple #3
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');
 }