/** * @see FrontController::postProcess() */ public function postProcess() { if (empty($_POST)) { $fap = json_decode(file_get_contents("php://input")); $_POST = array(); foreach ($fap as $key => $val) { $_POST[$key] = $val; } } try { if ($_POST['order_status'] == FondyCls::ORDER_DECLINED) { exit('Order declined'); } $fondy = new Fondy(); $settings = array('merchant_id' => $fondy->getOption('merchant'), 'secret_key' => $fondy->getOption('secret_key')); $isPaymentValid = FondyCls::isPaymentValid($settings, $_POST); if ($isPaymentValid !== true) { exit($isPaymentValid); } list($orderId, ) = explode(FondyCls::ORDER_SEPARATOR, $_POST['order_id']); $history = new OrderHistory(); $history->id_order = $orderId; $id_order_state = _PS_OS_PAYMENT_; $history->changeIdOrderState(intval($id_order_state), intval($orderId)); $history->addWithemail(true, ""); exit('OK'); } catch (Exception $e) { exit(get_class($e) . ': ' . $e->getMessage()); } }
/** * @see FrontController::postProcess() */ public function postProcess() { $fondy = new Fondy(); if ($_POST['order_status'] == FondyCls::ORDER_DECLINED) { $this->errors[] = Tools::displayError('Order declined'); } if ($_POST['order_status'] == 'processing') { $this->errors[] = Tools::displayError('Payment proccesing'); } $settings = array('merchant_id' => $fondy->getOption('merchant'), 'secret_key' => $fondy->getOption('secret_key')); $isPaymentValid = FondyCls::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(FondyCls::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); } }
/** * @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; $fondy = new Fondy(); $total = $cart->getOrderTotal(); $fondy->validateOrder(intval($cart->id), _PS_OS_PREPARATION_, $total, $fondy->displayName); $fields = array('order_id' => $fondy->currentOrder . FondyCls::ORDER_SEPARATOR . time(), 'merchant_id' => $fondy->getOption('merchant'), 'order_desc' => $fondy->currentOrder, 'amount' => round($total * 100), 'currency' => $payCurrency->iso_code, 'server_callback_url' => $link->getModuleLink('fondy', 'callback'), 'response_url' => $link->getModuleLink('fondy', 'result'), 'lang' => strtoupper($language), 'sender_email' => $this->context->customer->email); $fields['signature'] = FondyCls::getSignature($fields, $fondy->getOption('secret_key')); $fields['fondy_url'] = FondyCls::URL; $this->context->smarty->assign($fields); $this->setTemplate('redirect.tpl'); }
/** * @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); $fondy = new Fondy(); $total = $cart->getOrderTotal(); $callback = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/fondy/callback.php'; $result = _PS_BASE_URL_ . __PS_BASE_URI__ . 'modules/fondy/result.php'; $fondy->validateOrder(intval($cart->id), _PS_OS_PREPARATION_, $total, $fondy->displayName); $fields = array('order_id' => $fondy->currentOrder . FondyCls::ORDER_SEPARATOR . time(), 'merchant_id' => $fondy->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'] = FondyCls::getSignature($fields, $fondy->getOption('secret_key')); $fields['fondy_url'] = FondyCls::URL; $smarty->assign($fields); echo $this->display('redirect.tpl'); }