예제 #1
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);
     }
 }
예제 #2
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());
     }
 }
예제 #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
<?php

/**
 * Created by PhpStorm.
 * User: helcy
 * Date: 12.09.14
 * Time: 9:05
 */
require_once dirname(__FILE__) . '/fondy.php';
$module = new Fondy();
$smarty->assign('message', 'Payment was successful');
// Display all and exit
include _PS_ROOT_DIR_ . '/header.php';
echo $module->display(__FILE__, 'result-success.tpl');
include _PS_ROOT_DIR_ . '/footer.php';
die;
예제 #6
0
 function plgVmOnPaymentNotification()
 {
     if (empty($_POST)) {
         $fap = json_decode(file_get_contents("php://input"));
         $_POST = array();
         foreach ($fap as $key => $val) {
             $_POST[$key] = $val;
         }
     }
     $_SERVER['REQUEST_URI'] = '';
     $_SERVER['SCRIPT_NAME'] = '';
     $_SERVER['QUERY_STRING'] = '';
     define('_JEXEC', 1);
     define('DS', DIRECTORY_SEPARATOR);
     $option = 'com_virtuemart';
     $my_path = dirname(__FILE__);
     $my_path = explode(DS . 'plugins', $my_path);
     $my_path = $my_path[0];
     if (file_exists($my_path . '/defines.php')) {
         include_once $my_path . '/defines.php';
     }
     if (!defined('_JDEFINES')) {
         define('JPATH_BASE', $my_path);
         require_once JPATH_BASE . '/includes/defines.php';
     }
     define('JPATH_COMPONENT', JPATH_BASE . '/components/' . $option);
     define('JPATH_COMPONENT_SITE', JPATH_SITE . '/components/' . $option);
     define('JPATH_COMPONENT_ADMINISTRATOR', JPATH_ADMINISTRATOR . '/components/' . $option);
     require_once JPATH_BASE . '/includes/framework.php';
     $app = JFactory::getApplication('site');
     $app->initialise();
     if (!class_exists('VmConfig')) {
         require JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_virtuemart' . DS . 'helpers' . DS . 'config.php';
     }
     VmConfig::loadConfig();
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.fphp';
     }
     if (!class_exists('plgVmPaymentFondy')) {
         require dirname(__FILE__) . DS . 'fondy.php';
     }
     require dirname(__FILE__) . DS . 'Fondy.cls.php';
     //print_r ($_POST);die;
     list($order_id, ) = explode(Fondy::ORDER_SEPARATOR, $_POST['order_id']);
     $order = new VirtueMartModelOrders();
     $method = new plgVmPaymentFondy();
     $order_s_id = $order->getOrderIdByOrderNumber($order_id);
     $orderitems = $order->getOrder($order_s_id);
     $methoditems = $method->__getVmPluginMethod($orderitems['details']['BT']->virtuemart_paymentmethod_id);
     $option = array('merchant_id' => $methoditems->FONDY_MERCHANT, 'secret_key' => $methoditems->FONDY_SECRET_KEY);
     $response = Fondy::isPaymentValid($option, $_POST);
     if ($response === true) {
         $red = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&pm=' . $paymentMethodID);
         header('Location:' . $red);
         $datetime = date("YmdHis");
         echo "OK";
     } else {
         echo "<!-- {$response} -->";
     }
     $orderitems['order_status'] = $methoditems->status_success;
     $orderitems['customer_notified'] = 0;
     $orderitems['virtuemart_order_id'] = $order_s_id;
     $orderitems['comments'] = 'Fondy ID: ' . $order_id . " Ref ID : " . $_POST['payment_id'];
     $order->updateStatusForOneOrder($order_s_id, $orderitems, true);
 }
예제 #7
0
파일: fondy.php 프로젝트: cloudipsp/modx
<?php

define('MODX_API_MODE', true);
require dirname(dirname(dirname(dirname(dirname(__FILE__))))) . '/index.php';
$modx->getService('error', 'error.modError');
$modx->setLogLevel(modX::LOG_LEVEL_ERROR);
$modx->setLogTarget('FILE');
$miniShop2 = $modx->getService('minishop2');
$miniShop2->loadCustomClasses('payment');
if (!class_exists('Fondy')) {
    exit('Error: could not load payment class "Fondy".');
}
$context = '';
$params = array();
$handler = new Fondy($modx->newObject('msOrder'));
//print_r ($_POST); die;
if (empty($_POST)) {
    $fap = json_decode(file_get_contents("php://input"));
    $_POST = array();
    foreach ($fap as $key => $val) {
        $_POST[$key] = $val;
    }
    $request = $_POST;
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
    if ($_POST["response_status"] != 'success') {
        echo "Error";
        die;
    } elseif ($_POST['order_status'] != 'approved') {
        echo "Error order status";
        die;
예제 #8
0
/**
 * Function pay_get
 **/
function pay_get()
{
    global $gData;
    //    echo "<pre>";
    //    print_r($_POST);
    //    exit;
    // Connect to Data
    $gData = data_connect();
    list($orderId, ) = explode(FONDY::ORDER_SEPARATOR, $_POST['order_id']);
    list(, $orderId) = explode('-', $orderId);
    $order = $gData->GetArchiveOrder($orderId * 1);
    $fondy = new Fondy();
    $settings = array('merchant' => MERCHANT_ID, 'secretkey' => MERCHANT_SECRET);
    $invoice_url = HOST_NAME . 'invoice.php?order_id=' . $orderId . '&order_sid=' . $order['sid'];
    if ($_POST['order_status'] == Fondy::ORDER_DECLINED) {
        header('location: ' . $invoice_url);
    }
    $paymentInfo = $fondy->isPaymentValid($settings, $_REQUEST);
    if ($paymentInfo === true && isset($_REQUEST['send_email']) && !empty($_REQUEST['send_email'])) {
        $content = sendEmailToAdmin($order);
        return $content;
    } else {
        header('location: ' . $invoice_url);
    }
}
예제 #9
-1
<?php

/**
 * Created by PhpStorm.
 * User: helcy
 * Date: 12.09.14
 * Time: 9:05
 */
require_once dirname(__FILE__) . '/fondy.php';
$module = new Fondy();
$smarty->assign('message', $_GET['message']);
// Display all and exit
include _PS_ROOT_DIR_ . '/header.php';
echo $module->display(__FILE__, 'result-error.tpl');
include _PS_ROOT_DIR_ . '/footer.php';
die;