示例#1
0
 public static function setConfig()
 {
     $module = new PayqrModule();
     PayqrConfig::$merchantID = $module->getOption("merchantID");
     PayqrConfig::$secretKeyIn = $module->getOption("secretKeyIn");
     PayqrConfig::$secretKeyOut = $module->getOption("secretKeyOut");
 }
示例#2
0
 /**
  * Задаём настройки
  */
 private function setModuleConfig()
 {
     $user_id = isset($_GET["user_id"]) ? $_GET["user_id"] : 1;
     $auth = new PayqrModuleAuth($user_id);
     $module = new PayqrModule();
     PayqrConfig::$merchantID = $module->getOption("merchantID");
     PayqrConfig::$secretKeyIn = $module->getOption("secretKeyIn");
     PayqrConfig::$secretKeyOut = $module->getOption("secretKeyOut");
 }
 public function getLogUrl()
 {
     $url = "";
     $auth = new PayqrModuleAuth();
     if ($user = $auth->getUser()) {
         $url = PayqrConfig::getBaseUrl() . "/log.php?user_id={$user->user_id}&key={$this->log_key}";
     }
     return $url;
 }
示例#4
0
 public static function getLogFilePath()
 {
     if (!empty(PayqrConfig::$logFilePath)) {
         $path = PayqrConfig::getSiteBasePath() . PayqrConfig::$logFilePath;
     } else {
         $settings = new PayqrButtonDefaultSettings();
         $path = PayqrConfig::getSiteBasePath() . $settings->getLogPath();
     }
     return $path;
 }
示例#5
0
 public static function redirect($path, $params = array())
 {
     $location = PayqrConfig::getBaseUrl() . "/module/index.php?path={$path}";
     if (count($params) > 0) {
         $url = "";
         foreach ($params as $key => $value) {
             $url .= "&{$key}={$value}";
         }
         $location .= $url;
     }
     header("Location: {$location}");
 }
示例#6
0
 public static function init()
 {
     //получаем информацию о настройках кнопки
     $marketObj = new Market();
     $market = $marketObj->getUserMarkets(DEFAULT_USER_ID)->one();
     if (!isset($market->settings)) {
         PayqrLog::log("Не смогли получить настройки кнопки, прекращаем работу!");
         return false;
     }
     $settings = json_decode($market->getSettings(), true);
     if (!isset($settings['merchant_id'], $settings['secret_key_in'], $settings['secret_key_out'], $settings['insales_url']) && (empty($settings['merchant_id']) || empty($settings['secret_key_in']) || empty($settings['secret_key_out']) || empty($settings['insales_url']))) {
         return false;
     }
     self::$merchantID = $settings['merchant_id'];
     self::$secretKeyIn = $settings['secret_key_in'];
     self::$secretKeyOut = $settings['secret_key_out'];
     self::$insalesURL = $settings['insales_url'];
 }
示例#7
0
<?php

/**
 * Скрипт принимает и обрабатывает уведомления от PayQR
 */
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');
require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';
require __DIR__ . '/../common/config/bootstrap.php';
require __DIR__ . '/../console/config/bootstrap.php';
$config = yii\helpers\ArrayHelper::merge(require __DIR__ . '/../common/config/main.php', require __DIR__ . '/../common/config/main-local.php', require __DIR__ . '/../console/config/main.php', require __DIR__ . '/../console/config/main-local.php');
$application = new yii\console\Application($config);
$exitCode = $application->run();
require_once __DIR__ . "/PayqrConfig.php";
// подключаем основной класс
//инициализируем данными нашу библиотеку
if (PayqrConfig::init()) {
    exit("Error init PayQR market!");
}
try {
    $receiver = new PayqrReceiver();
    $receiver->handle();
} catch (PayqrExeption $e) {
    echo $e->response;
}
exit($exitCode);
示例#8
0
<head>
  <meta charset="utf-8">
  <?php 
echo PayqrButton::getJs();
?>
</head>
<body>
  <?php 
echo $button->getHtmlButton();
?>
    <div style="margin: 20px;">
        <a href="<?php 
echo PayqrConfig::getBaseUrl();
?>
/payqr/example/sender.php">Административные функции</a>
        <br/>
        <a href="<?php 
echo PayqrConfig::getBaseUrl();
?>
/payqr/log.php?key=<?php 
echo PayqrConfig::$logKey;
?>
">Логи</a>
        <br/>
        <a>Url: <?php 
echo PayqrConfig::getBaseUrl();
?>
/payqr/handler.php</a>
    </div>
</body>
</html>
 public function handle($data)
 {
     PayqrConfig::setConfig();
     if (isset($data["invoice_action"])) {
         $order_id = $data["order_id"];
         $action = $data["invoice_action"];
         $invoice_id = $data["invoice_id"];
         if ($this->validate($data)) {
             $invAction = new PayqrInvoiceAction();
             switch ($action) {
                 case "invoice_cancel":
                     $invAction->invoice_cancel($invoice_id);
                     $order = new PayqrOrder();
                     $order->cancelOrder();
                     break;
                 case "invoice_revert":
                     $revert_amount = $data["invoice_revert_amount"];
                     $invAction->invoice_revert($invoice_id, $revert_amount);
                     break;
                 case "invoice_confirm":
                     $invAction->invoice_confirm($invoice_id);
                     break;
                 case "invoice_execution_confirm":
                     $invAction->invoice_execution_confirm($invoice_id);
                     break;
                 case "invoice_message":
                     $text = $data["invoice_message_text"];
                     $image_url = $data["invoice_message_image_url"];
                     $click_url = $data["invoice_message_click_url"];
                     $invAction->invoice_message($invoice_id, $text, $image_url, $click_url);
                     break;
                 case "invoice_sync_data":
                     $order = new PayqrOrder();
                     $order->syncOrder();
                     break;
             }
         }
     }
 }
示例#10
0
 /**
  * Задаём настройки
  */
 private function setModuleConfig()
 {
     $user_id = isset($_GET["user_id"]) ? $_GET["user_id"] : 1;
     $auth = new PayqrModuleAuth($user_id);
     PayqrConfig::setConfig();
 }