Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $config = require "../config.php";
- require "../database.php";
- if(isset($_REQUEST["ch"])) {
- $username = $_REQUEST["ch"][0];
- array_shift($_REQUEST["ch"]);
- if(count($_REQUEST["ch"]) > 0) {
- $database = new DataBase(
- $config["mysql"]["host"],
- $config["mysql"]["user"],
- $config["mysql"]["password"],
- $config["mysql"]["database"]
- );
- $cost = 0;
- foreach($_REQUEST["ch"] as $row) {
- $ex = explode("-", $row);
- $cost = $cost + $config["capabilities"][$ex[1]]["cost"];
- }
- $database->query("CREATE TABLE IF NOT EXISTS `cd_payments` (
- `id` int(11) NOT NULL AUTO_INCREMENT,
- `values` text NOT NULL,
- `username` text NOT NULL,
- `status` int(11) NOT NULL,
- `sum` int(11) NOT NULL,
- PRIMARY KEY (`id`)
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=1");
- function getFormSignature($account, $desc, $sum) {
- $hashStr = $account.'{up}'.$desc.'{up}'.$sum.'{up}'.$config["unitpay"]["secret_key"];
- return hash('sha256', $hashStr);
- }
- $data = implode(",", $_REQUEST["ch"]);
- $account = $database->query("INSERT INTO `cd_payments` (`id`, `values`, `username`, `status`, `sum`) VALUES (NULL, {?}, {?}, {?}, {?})", [$data, $username, 0, $cost]);
- $account = $account."_construct";
- $message = "Создание доната в конструкторе для игрока {$username}";
- $public_key = $config["unitpay"]["public_key"];
- $signature = getFormSignature($account, $message, $cost);
- $unitpay_uri = "https://unitpay.ru/pay/{$public_key}/qiwi?sum={$cost}&account={$account}&desc={$message}&signature={$signature}";
- die(json_encode(array("status" => "success", "uri" => $unitpay_uri)));
- } else {
- die(json_encode(array("status" => "fail", "message" => "Выберите любую возможность")));
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement