/** * @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); } }
/** * @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'); }
/** * @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'); }
/** * @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()); } }
public static function isPaymentValid($oplataSettings, $response) { if ($oplataSettings['MERCHANT'] != $response['merchant_id']) { return 'An error has occurred during payment. Merchant data is incorrect.'; } //print_r ($oplataSettings); die; $responseSignature = $response['signature']; if (isset($response['response_signature_string'])) { unset($response['response_signature_string']); } if (isset($response['signature'])) { unset($response['signature']); } if (Oplata::getSignature($response, $oplataSettings['SECURE_KEY']) != $responseSignature) { return 'An error has occurred during payment. Signature is not valid.'; } return true; }
public function callback() { $options = array('merchant' => $this->config->get('oplata_merchant'), 'secretkey' => $this->config->get('oplata_secretkey')); if ($_POST['order_status'] == Oplata::ORDER_DECLINED) { exit('Order declined'); } $paymentInfo = Oplata::isPaymentValid($options, $_POST); if ($paymentInfo === true) { list($order_id, ) = explode(Oplata::ORDER_SEPARATOR, $_POST['order_id']); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); $this->model_checkout_order->confirm($order_id, $this->config->get('oplata_order_status_id')); echo "OK"; // $this->msg['message'] = "Thank you for shopping with us. Your account has been charged and your transaction is successful."; // $this->msg['class'] = 'woocommerce-message'; } else { // $this->msg['class'] = 'error'; // $this->msg['message'] = $paymentInfo; echo $paymentInfo; } }
<?php /** * Created by PhpStorm. * User: helcy * Date: 12.09.14 * Time: 9:05 */ require_once dirname(__FILE__) . '/oplata.php'; $module = new Oplata(); $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;
if (!(require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/prolog_before.php")) { die('prolog_before.php not found!'); } if (CModule::IncludeModule('sale')) { $ordArray = explode("_", $_POST['order_id']); $ORDER_ID = $ordArray[1]; $User_ID = $ordArray[2]; $arOrder = CSaleOrder::GetByID($ORDER_ID); $payID = $arOrder['PAY_SYSTEM_ID']; $temp = CSalePaySystemAction::GetList(array(), array("PAY_SYSTEM_ID" => $payID)); $payData = $temp->Fetch(); include $_SERVER['DOCUMENT_ROOT'] . $payData['ACTION_FILE'] . "/oplata.cls.php"; $oplataOpt = array(); $b = unserialize($payData['PARAMS']); foreach ($b as $k => $v) { $oplataOpt[$k] = $v['VALUE']; } $oplata = new Oplata(); $oplataResult = $oplata->isPaymentValid($oplataOpt, $_REQUEST); if ($_REQUEST['order_status'] == Oplata::ORDER_DECLINED) { $answer = 'declined'; } elseif ($oplataResult === true) { $answer = 'OK'; } else { $answer = $oplataResult; } $arFields = array("STATUS_ID" => $answer == 'OK' ? "P" : "N", "PAYED" => $answer == 'OK' ? "Y" : "N", "PS_STATUS" => $answer == 'OK' ? "Y" : "N", "PS_STATUS_CODE" => $_POST['order_status'], "PS_STATUS_DESCRIPTION" => $_POST['order_status'] . " " . $payID . " " . ($answer != 'OK' ? $_REQUEST['response_description'] : ''), "PS_STATUS_MESSAGE" => " - ", "PS_SUM" => $_POST['amount'], "PS_CURRENCY" => $_POST['currency'], "PS_RESPONSE_DATE" => date("d.m.Y H:i:s")); CSaleOrder::Update($ORDER_ID, $arFields); echo $answer; } require $_SERVER["DOCUMENT_ROOT"] . "/bitrix/modules/main/include/epilog_after.php";
} else { $ORDER_ID = $_GET['ORDER_ID']; } #-------------------------------------------- $ORDER_ID = filter_var($ORDER_ID, FILTER_SANITIZE_NUMBER_INT); $arOrder = CSaleOrder::GetByID($ORDER_ID); $orderID = "Order_" . $ORDER_ID . "_" . CSaleBasket::GetBasketUserID() . "_" . md5("Order_" . time()); $shouldPay = strlen(CSalePaySystemAction::GetParamValue("SHOULD_PAY", '')) > 0 ? CSalePaySystemAction::GetParamValue("SHOULD_PAY", 0) : $GLOBALS["SALE_INPUT_PARAMS"]["ORDER"]["SHOULD_PAY"]; if (CSalePaySystemAction::GetParamValue("ONPAGE") != 'Y') { $amount = round($shouldPay * 100); } else { $amount = $shouldPay; } $formFields = array('order_id' => $orderID, 'merchant_id' => CSalePaySystemAction::GetParamValue("MERCHANT"), 'order_desc' => $orderID, 'amount' => $amount, 'currency' => CSalePaySystemAction::GetParamValue("PRICE_CURRENCY"), 'server_callback_url' => CSalePaySystemAction::GetParamValue("SERVER_CALLBACK_URL"), 'response_url' => CSalePaySystemAction::GetParamValue("SERVER_CALLBACK_URL"), 'lang' => CSalePaySystemAction::GetParamValue("LANGUAGE"), 'sender_email' => $USER->GetEmail()); //print_r ($formFields); die; $formFields['signature'] = Oplata::getSignature($formFields, CSalePaySystemAction::GetParamValue("SECURE_KEY")); //print_r (CSalePaySystemAction::GetParamValue("ONPAGE"));die; $oplataArgsArray = array(); foreach ($formFields as $key => $value) { $oplataArgsArray[] = "<input type='hidden' name='{$key}' value='{$value}'/>"; } if (CSalePaySystemAction::GetParamValue("ONPAGE") != 'Y') { $out = ' <form action="' . Oplata::URL . '" method="post" id="oplata_payment_form"> ' . implode('', $oplataArgsArray) . '</form>' . "<div><img src='https://oplata.com/img/loader.gif' width='50px' style='margin:20px 20px;'></div>" . "<script> setTimeout(function() {\n document.getElementById('oplata_payment_form').submit();\n }, 100);\n </script>"; } else { $out = "<script>\n\tvar checkoutStyles = {\n\t\t'html , body' : {\n\t\t\t'overflow' : 'hidden'\n\t\t\t},'.col.col-shoplogo' : {\n\t\t\t'display' : 'none'\n\t\t},\n\t\t'.col.col-language' : {\n\t\t\t'display' : 'none'\n\t\t},\n\t\t'.pages-checkout' : {\n\t\t\t'background' : 'transparent'\n\t\t},\n\t\t'.col.col-login' : {\n\t\t\t'display' : 'none'\n\t\t},\n\t\t'.pages-checkout .page-section-overview' : {\n\t\t\t'background' : '#fff',\n\t\t\t'color' : '#252525',\n\t\t\t'border-bottom' : '1px solid #dfdfdf'\n\t\t},\n\t\t'.col.col-value.order-content' : {\n\t\t\t'color' : '#252525'\n\t\t},\n\t\t'.page-section-footer' : {\n\t\t\t'display' : 'none'\n\t\t},\n\t\t'.page-section-tabs' : {\n\t\t\t'display' : 'none'\n\t\t},\n\t\t\n\t\t'.page-section-shopinfo' : {\n\t\t\t'display': 'none'\n\t\t},\n\t\t\n\t\t'.page-section-overview' : {\n\t\t\t'display': 'none'\n\t\t},\n\t}\n\t</script>"; $out .= '<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script> <script src="https://api.fondy.eu/static_common/v1/checkout/ipsp.js"></script> <div id="checkout"> <div id="checkout_wrapper" style="width:600px;"></div> </div>
<?php /** * Created by PhpStorm. * User: helcy * Date: 12.09.14 * Time: 9:05 */ require_once dirname(__FILE__) . '/oplata.php'; $module = new Oplata(); $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;