/** * @Route("/api/pay/confirm/{hash}", name="api-confirm-payment", options={"expose"=true}) * @param Request $request * @param string $hash * @return JsonResponse */ public function confirmOrder(Request $request, $hash) { $liqpay = new \LiqPay($this->public_key, $this->private_key); $res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $hash)); /** @var EntityManager $em */ $em = $this->getDoctrine()->getManager(); /** @var User $user */ $user = $this->getUser(); $order = $em->getRepository('NaidusvoeBundle:Order')->findOneBy(['hash' => $hash]); if ($user->getId() !== $order->getUserId()) { new JsonResponse(['status' => 'error', 'message' => 'NOT_ALLOWED']); } $payment = $em->getRepository('NaidusvoeBundle:Payment')->findOneBy(['hash' => $hash]); if ($payment === null) { switch ($res['status']) { case 'success': case 'sandbox': return $this->handleConfirmation($order, $res); case 'failure': case 'error': case '3ds_verify': case 'wait_secure': case 'wait_accept': case 'processing': break; default: break; } return new JsonResponse(['status' => 'error', 'message' => 'PAYMENT_FAILED']); } else { return new JsonResponse(['status' => 'ok', 'details' => $payment->getDetails()]); } }
public static function getPayForm($zakaz) { $liqp = array('amount' => $zakaz->sum, 'currency' => 'UAH', 'description' => 'Оплата почтовых услуг', 'order_id' => 'order_' . $zakaz->id, 'language' => 'en', 'result_url' => 'http://vkonverte.com.ua/?action=saveLiqPay&id=' . $zakaz->id, 'type' => 'buy'); $public_key = "i2585333566"; $private_key = "11gIelq1UB7amSrjYz7SsA1dFcyRq9ji5GJnPpHo"; $liqpay = new LiqPay($public_key, $private_key); return $liqpay->cnb_form($liqp); }
public function __construct($context) { parent::__construct(); $this->context = $context; $public_key = "i2585333566"; $private_key = "11gIelq1UB7amSrjYz7SsA1dFcyRq9ji5GJnPpHo"; $tovar = array('amount' => '6', 'currency' => 'UAH', 'description' => 'Оплата почтовых услуг', 'order_id' => 'order_' . date('YmdHi', time()), 'type' => 'buy'); $liqpay = new LiqPay($public_key, $private_key); $form = $liqpay->cnb_form($tovar); $sign = $liqpay->cnb_signature($tovar); $this->context->payform = $form; $this->context->signature = $sign; $this->runame = get_class($this); }
/** * This is the default 'index' action that is invoked * when an action is not explicitly requested by users. */ public function actionIndex() { $this->layout = 'main'; $sql = "SELECT\n ID,\n DATE_FORMAT(post_date, '%d/%m/%Y') AS p_date,\n post_title,\n post_content,\n guid\n FROM wp_posts\n WHERE post_status = 'publish'\n ORDER BY post_date DESC\n LIMIT 3"; $blogArticles = Yii::app()->db->createCommand($sql)->queryAll(); $liqPayConfig = Yii::app()->config->payment['liqpay']; $liqpay = new LiqPay($liqPayConfig['public_key'], $liqPayConfig['private_key']); $liqPayConfig['order_id'] = 'czvldonate' . date('ymdHi') . rand(100, 1000); $liqPayConfig['signature'] = $liqpay->cnb_signature($liqPayConfig); $this->render('index', array('blog_articles' => $blogArticles, 'liqpay' => $liqPayConfig)); }
{!! Form::text('product', '', ['class' => 'form-control', 'id' => 'product', 'placeholder' => 'Введите название']) !!} {!! Form::hidden('status_id', '', ['id' => 'status_id']) !!} <div class='products'> <table class="table table-striped"> </table> </div> </div> <?php $public_key = "34567898765"; $private_key = "23456789876"; $liqpay = new LiqPay($public_key, $private_key); $html = $liqpay->cnb_form(array('version' => '1.0', 'amount' => '1', 'currency' => 'RUB', 'description' => 'description text', 'order_id' => '32', 'type' => 'buy')); echo $html; $liqpay = new LiqPay($public_key, $private_key); $html = $liqpay->cnb_signature(array('version' => '1.0', 'amount' => '1', 'currency' => 'USD', 'description' => 'description text', 'order_id' => 32, 'type' => 'buy')); echo $html; ?> <!-- {!!Form::open(['url' => 'https://www.liqpay.com/api/pay'])!!} <input type="hidden" name="_token" value="{{ csrf_token() }}"> {!! Form::hidden('public_key', 'igregreg') !!} {!! Form::hidden('amount', '5') !!} {!! Form::hidden('currency', 'USD') !!} {!! Form::hidden('description', 'Мой товар') !!} {!! Form::hidden('order_id', '123456') !!} {!! Form::hidden('result_url', 'http://i.com/back') !!} {!! Form::hidden('server_url', 'http://i.com/call') !!}
echo 'http://' . $_SERVER['HTTP_HOST']; die; } $amount = $request->totalPrice->sum; try { $db = new Database(); $db->beginTransaction(); $response = $db->insertClient($request->textMessage, $request->phoneNumber, $amount, json_encode($request)); if (!$response['state']) { die('Server error. Please contact to administrator.'); } if ($request->paymentMethod == 'onlinePayment') { // online paid $publicKey = $params['liqpay']['publicKey']; $privateKey = $params['liqpay']['privateKey']; $lp = new LiqPay($publicKey, $privateKey); $url = $lp->cnb_form(array('version' => '3', 'amount' => $amount, 'currency' => 'UAH', 'description' => 'payment for order ' . $response['id'] . ' for burgerjoint.com.ua', 'server_url' => "http://{$_SERVER['HTTP_HOST']}/scripts/server.php", 'result_url' => "http://{$_SERVER['HTTP_HOST']}/scripts/result.php?id={$response['id']}", 'order_id' => $response['id'])); } else { $sms = new SmsClient($params['SmsUkraine']['login'], $params['SmsUkraine']['password']); $email = new Email(); if ($email->sendEmail($request, true, $response['id'])) { $db->setAsPaid($response['id']); $sms->sendSMS('BurgerJoint', $params['adminNumber'], 'Нове замовлення ' . $response['id']); $url = 'http://' . $_SERVER['HTTP_HOST'] . '/index.html#/success'; } else { $url = 'http://' . $_SERVER['HTTP_HOST'] . '/index.html#/failure'; } } $db->commit(); echo $url; die;
<?php require 'classes/database.class.php'; require 'classes/LiqPay.php'; require 'classes/email.class.php'; require 'classes/smsclient.class.php'; $params = (require 'params.php'); $publicKey = $params['liqpay']['publicKey']; $privateKey = $params['liqpay']['privateKey']; $liqpay = new LiqPay($publicKey, $privateKey); $db = new Database(); $email = new Email(); $allInActiveOrder = $db->getInactiveOrders(); $sms = new SmsClient($params['SmsUkraine']['login'], $params['SmsUkraine']['password']); foreach ($allInActiveOrder as $order) { $res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $order['clientId'])); if ($res->result == 'error') { if ($db->sendErrorSms($order['clientId'])) { if ($db->setAsError($order['clientId'])) { $sms->sendSMS('BurgerJoint', $order['phoneNumber'], 'Ваше замовлення скасовано. Для детальної iнформацiї звертайтесь за телефоном +38 (068) 235 50 29'); } } } elseif ($res->result == 'ok') { if ($res->amount != $order['amount']) { $temp = ['res' => $res->amount, 'amount' => $order['amount'], 'check' => $res->amount != $order['amount']]; $db->setAsError($res->order_id); $sms->sendSMS('BurgerJoint', $res->sender_phone, 'Ваше замовлення скасовано. Для детальної iнформацiї звертайтесь за телефоном +38 (068) 235 50 29'); $htmlString = $email->postDataToString(array_merge((array) $res, ['-' => '-'], $order, $temp)); $email->sendEmail('Данi не спiвпадають' . $htmlString, false, $order['clientId']); } else { if ($db->setAsPaid($order['clientId'])) {
function view($postId) { $this->view->canon = 'payment'; $this->view->titl = 'Select payment method'; $this->view->post = $this->model->singlePost($postId); $micro = sprintf("%06d", (microtime(true) - floor(microtime(true))) * 1000000); // Ну раз что-то нужно добавить для полной уникализации то .. $number = date("YmdHis"); //Все вместе будет первой частью номера ордера $order_id = $number . $micro; //Будем формировать номер ордера таким образом... $merchant_id = 'i71658652626'; //Вписывайте сюда свой мерчант $signature = "NdIKOaHg7r1TulEe82hIzrmt8UqqYnuYtXUdXDnt"; //Сюда вносите public_key //$desc = $_GET['desc']; //Можно так принять назначение платежа //$order_id = $_GET['order_id']; //Можно так принять назначение платежа $price = $this->view->post[0]['price']; //Все что нужно скрипту - передать в него сумму (вы можете передавать все, вплоть до ордера и описания ...) $postToPay = $this->view->post[0]['postid']; $liqpay = new LiqPay($merchant_id, $signature); $html = $liqpay->cnb_form(array('version' => '3', 'amount' => "{$price}", 'currency' => 'USD', 'description' => "Post №{$postToPay}", 'order_id' => $order_id, 'language' => 'en', 'server_url' => 'http://dotnetnow.com/thanks/callback', 'result_url' => 'http://dotnetnow.com/thanks/success')); $this->view->htm = $html; $this->view->render('payment/index', TRUE); }
public function process($template = null) { $order = $this->order; $order->order(); $order->setPaymentStatus('initialized'); // Ставим заказу статус "инициализирована оплата" // Загружаем API класс LiqPay objectProxyHelper::includeClass('emarket/classes/payment/api/', 'LiqPay'); $liqpay = new LiqPay($this->getValue('public_key'), $this->getValue('private_key')); $sandbox_status = 0; if ($this->getValue('sandbox_status')) { $sandbox_status = 1; } $domain = $_SERVER['HTTP_HOST']; $html = $liqpay->cnb_form(array('version' => '3', 'sandbox' => $sandbox_status, 'amount' => $order->getActualPrice(), 'currency' => $this->getValue('currency'), 'description' => $this->getValue('desc'), 'pay_way' => $this->getValue('pay_way'), 'order_id' => $order->getId(), 'type' => 'buy', 'result_url' => $domain . '/emarket/purchase/result/successful/?order_id=' . $order->getId() . '&order_type=liq_pay')); $param = array(); $param['form_html'] = $html; list($templateString) = def_module::loadTemplates("emarket/payment/liqpay/" . $template, "form_block"); return def_module::parseTemplate($templateString, $param); }
<?php require 'classes/LiqPay.php'; $params = (require 'params.php'); $publicKey = $params['liqpay']['publicKey']; $privateKey = $params['liqpay']['privateKey']; $id = $_GET['id']; $liqpay = new LiqPay($publicKey, $privateKey); $res = $liqpay->api("payment/status", array('version' => '3', 'order_id' => $id)); if ($res->result == 'ok') { header("Location: /index.html#/success"); } elseif ($res->result == 'error') { header("Location: /index.html#/failure"); } else { header("Location: /index.html#/pending"); }
/** * Created by PhpStorm. * User: zvorskyi * Date: 01.12.2015 * Time: 12:16 */ if (isset($_POST['Mode'])) { $public_key = "i22615008395"; $private_key = "wPd44vyFAeu8BzJwxnhehkJeB6Viwj6Z7SdLcOOS"; $curr_date = getdate(); $reg_day = $curr_date["mday"]; $reg_hour = $curr_date["hours"]; $reg_min = $curr_date["minutes"]; $reg_sec = $curr_date["seconds"]; $order_id = "order#" . $reg_day . $reg_hour . $reg_min . $reg_sec; if ($_POST['Mode'] == "350h") { $description = "Оплата тренинга"; $amount = 350; } elseif ($_POST['Mode'] == "500h") { $description = "Оплата тренинга"; $amount = 500; } else { $description = "Предоплата тренинга"; $amount = 100; } require_once "Liquid.php"; $liqpay = new LiqPay($public_key, $private_key); $html = $liqpay->cnb_form(array('version' => '3', 'amount' => $amount, 'currency' => 'UAH', 'description' => $description, 'order_id' => $order_id, 'type' => 'buy', 'language' => 'uk')); echo json_encode($html); }
/** * Display the payment form * @param $queuedPaymentId int * @param $queuedPayment QueuedPayment * @param $request PKPRequest */ function displayPaymentForm($queuedPaymentId, &$queuedPayment, &$request) { if (!$this->isConfigured()) { return false; } AppLocale::requireComponents(LOCALE_COMPONENT_APPLICATION_COMMON); $journal =& $request->getJournal(); $user =& $request->getUser(); $assocId = $queuedPayment->getAssocId(); $authorSubmissionDao =& DAORegistry::getDAO('AuthorSubmissionDAO'); $authorSubmission =& $authorSubmissionDao->getAuthorSubmission($assocId); $docObj = new Filetotext($authorSubmission->getSubmissionFile()->getFilePath()); $text = $docObj->convertToText(); $amount = mb_strlen($text) / 1000 * $queuedPayment->getAmount(); $liqpay = new LiqPay($this->getSetting($journal->getId(), 'liqpaypubkey'), $this->getSetting($journal->getId(), 'liqpayprivatkey')); if ($this->getSetting($journal->getId(), 'liqpaydebug')) { $debug = 1; } else { $debug = 0; } $html = $liqpay->cnb_form(array('version' => '3', 'amount' => $amount, 'currency' => $queuedPayment->getCurrencyCode(), 'description' => 'Payment for article ' . $assocId . '/' . $queuedPaymentId, 'order_id' => $assocId, 'result_url' => $queuedPayment->getRequestUrl(), 'sandbox' => $debug, 'server_url' => $request->url(null, 'payment', 'plugin', array($this->getName(), 'notification')))); var_dump($request->url(null, 'payment', 'plugin', array($this->getName(), 'notification'))); $params = array('charset' => Config::getVar('i18n', 'client_charset'), 'item_name' => $queuedPayment->getName(), 'item_description' => $queuedPayment->getDescription(), 'amount' => sprintf('%.2F', $amount), 'lc' => String::substr(AppLocale::getLocale(), 3), 'custom' => $queuedPaymentId, 'return' => $queuedPayment->getRequestUrl(), 'cancel_return' => $request->url(null, 'payment', 'plugin', array($this->getName(), 'cancel'))); // $params = array( // 'charset' => Config::getVar('i18n', 'client_charset'), // 'business' => $this->getSetting($journal->getId(), 'selleraccount'), // 'item_name' => $queuedPayment->getName(), // 'item_description' => $queuedPayment->getDescription(), // not a paypal parameter (PayPal uses item_name) // 'amount' => sprintf('%.2F', $queuedPayment->getAmount()), // 'quantity' => 1, // 'no_note' => 1, // 'no_shipping' => 1, // 'currency_code' => $queuedPayment->getCurrencyCode(), // 'lc' => String::substr(AppLocale::getLocale(), 3), // 'custom' => $queuedPaymentId, // 'notify_url' => $request->url(null, 'payment', 'plugin', array($this->getName(), 'ipn')), // 'return' => $queuedPayment->getRequestUrl(), // 'cancel_return' => $request->url(null, 'payment', 'plugin', array($this->getName(), 'cancel')), // 'first_name' => ($user)?$user->getFirstName():'', // 'last_name' => ($user)?$user->getLastname():'', // 'item_number' => $queuedPayment->getAssocId(), // 'cmd' => '_xclick' // ); AppLocale::requireComponents(LOCALE_COMPONENT_APPLICATION_COMMON); $templateMgr =& TemplateManager::getManager(); $templateMgr->assign('params', $params); $templateMgr->assign('formliqpay', $html); $templateMgr->assign('liqpayFormUrl', $this->getSetting($journal->getId(), 'liqpayurl')); $templateMgr->display($this->getTemplatePath() . 'paymentForm.tpl'); return true; }