예제 #1
0
 /**
  * @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());
     }
 }
예제 #2
0
 /**
  * @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);
     }
 }
예제 #3
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;
     $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');
 }
예제 #4
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);
     $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');
 }
예제 #5
0
 public function postProcess()
 {
     list($orderId, ) = explode(FondyCls::ORDER_SEPARATOR, $_POST['order_id']);
     $this->_order = new Order(intval($orderId));
     $this->_customer = new Customer($this->_order->id_customer);
     if ($_POST['order_status'] == FondyCls::ORDER_DECLINED) {
         $this->showError(Tools::displayError('Order declined'));
     }
     $settings = array('merchant_id' => $this->getOption('merchant'), 'secret_key' => $this->getOption('secret_key'));
     $isPaymentValid = FondyCls::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/fondy/result-success.php');
 }
예제 #6
0
파일: fondy.php 프로젝트: cloudipsp/cscart
            if ($_REQUEST['order_status'] == FondyCls::ORDER_APPROVED) {
                $pp_response['order_status'] = 'P';
                $pp_response['reason_text'] = __('transaction_approved');
                $pp_response['transaction_id'] = $_REQUEST['payment_id'];
                if (fn_check_payment_script('fondy.php', $order_id)) {
                    fn_finish_payment($order_id, $pp_response);
                    fn_order_placement_routines('route', $order_id);
                }
            }
        }
    } elseif ($mode == 'sucsses' && !empty($_REQUEST['order_id'])) {
        if ($response == true && $order_info['status'] == 'N') {
            if ($_REQUEST['order_status'] == FondyCls::ORDER_APPROVED) {
                $pp_response['order_status'] = 'P';
                $pp_response['reason_text'] = __('transaction_approved');
                $pp_response['transaction_id'] = $_REQUEST['payment_id'];
                fn_finish_payment($order_id, $pp_response);
            }
        }
    }
    exit;
} else {
    $payment_url = FondyCls::URL;
    $amount = fn_format_price($order_info['total'], $processor_data['processor_params']['currency']);
    $confirm_url = fn_url("payment_notification.sucsses?payment=fondy&order_id={$order_id}", AREA, 'current');
    $response_url = fn_url("payment_notification.response?payment=fondy&order_id={$order_id}", AREA, 'current');
    $post_data = array('merchant_id' => $processor_data['processor_params']['fondy_merchantid'], 'lang' => $processor_data['processor_params']['fondy_lang'], 'order_id' => time() . $order_id, 'order_desc' => '#' . $order_id, 'amount' => round($amount * 100), 'currency' => $processor_data['processor_params']['currency'], 'server_callback_url' => $confirm_url, 'response_url' => $response_url);
    $post_data['signature'] = FondyCls::getSignature($post_data, $processor_data['processor_params']['fondy_merchnatSecretKey']);
    fn_create_payment_form($payment_url, $post_data, 'Fondy', false);
    exit;
}