From 1088e6c4fdaab4275e36ffcceff7cf58d425e6d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=A0=D0=BE=D0=BC=D0=B0=20=D0=94=D0=B0=D0=BD=D0=B8=D0=BB?= =?UTF-8?q?=D0=BE=D0=B2?= <35975332+Nekiplay@users.noreply.github.com> Date: Tue, 7 Jul 2020 22:29:57 +0500 Subject: [PATCH] PayKassa bot (#1114) --- MinecraftClient/config/ChatBots/PayKassa.cs | 101 ++++++++++++++++++++ 1 file changed, 101 insertions(+) create mode 100644 MinecraftClient/config/ChatBots/PayKassa.cs diff --git a/MinecraftClient/config/ChatBots/PayKassa.cs b/MinecraftClient/config/ChatBots/PayKassa.cs new file mode 100644 index 00000000..95a56b98 --- /dev/null +++ b/MinecraftClient/config/ChatBots/PayKassa.cs @@ -0,0 +1,101 @@ +//MCCScript 1.0 +//using System.Threading.Tasks; + +//==== CONFIG START ==== +string merchant_id = ""; +string merchant_password = ""; +//==== CONFIG END ==== + +MCC.LoadBot(new PayKassaBot(merchant_id, merchant_password)); + +//MCCScript Extensions + +public class PayKassaBot : ChatBot +{ + private PayKassaSCI paykassa { get; set; } + + /// + /// This bot forwarding messages between Minecraft and VKonrakte chats. + /// Shares only messages that starts with dot ("."). Example: .Hello! + /// Also, send message to VK when any player joins or leaves. + /// + /// VK Community token + /// VK ChatId + /// Bot's CommunityId + public PayKassaBot(string merchant_id, string merchant_password) + { + paykassa = new PayKassaSCI(merchant_id, merchant_password); + } + +} + +/// +/// Client for VK Community (bot) LongPool API. +/// Also can send messages. +/// + +internal class PayKassaSCI +{ + private string _merchant_id = ""; + private string _merchant_password = ""; + public PayKassaSCI(string merchant_id, string merchant_password) + { + this._merchant_id = merchant_id; + this._merchant_password = merchant_password; + } + + public enum SystemID + { + Payeer = 1, + PerfectMoney = 2, + AdvCash = 4, + Berty = 7, + BitCoin = 11, + Ethereum = 12, + LiteCoin = 14, + DogeCoin = 15, + Dash = 16, + BitcoinCash = 18, + Zcash = 19, + EthereumClassic = 21, + Ripple = 22, + TRON = 27, + Stellar = 28, + + } + + public string[] sci_create_order(float ammount, string currency, string order_id, string comment, SystemID systemID) + { + using (WebClient web = new WebClient()) + { + string url = "https://paykassa.pro/sci/0.4/index.php?func=sci_create_order&sci_id" + _merchant_id + "&sci_id=" + _merchant_id + "&sci_key=" + _merchant_password + "&order_id=" + order_id + "&amount=" + ammount + "¤cy=" + currency + "&system=" + (int)systemID + "&comment=" + comment; + string response = web.DownloadString(url); + string urlresponse = Regex.Match(response, "{\"url\":\"(.*)\",\"method\"").Groups[1].Value; + urlresponse = urlresponse.Replace(@"\/", "/"); + string hash = Regex.Match(response, "\"hash\":\"(.*)\"}}}").Groups[1].Value; + return new string[] { urlresponse, hash }; + } + } + + public string[] sci_confirm_order(string private_hash) + { + using (WebClient web = new WebClient()) + { + string url = "https://paykassa.pro/sci/0.4/index.php?func=sci_confirm_order&sci_id" + _merchant_id + "&sci_id=" + _merchant_id + "&sci_key=" + _merchant_password + "&private_hash=" + private_hash + "&test=true"; + string response = web.DownloadString(url); + Console.WriteLine(response); + string error =Regex.Match(response, "\"error\":(.*),\"message\"").Groups[1].Value; + + string message = Regex.Match(response, "\"message\":\"(.*)\",\"data\"").Groups[1].Value; + + string transaction = Regex.Match(response, "\"transaction\":\"(.*)\",").Groups[1].Value; + string shop_id = Regex.Match(response, "\"shop_id\":\"(.*)\",").Groups[1].Value; + string order_id = Regex.Match(response, "\"order_id\":\"(.*)\",").Groups[1].Value; + string amount = Regex.Match(response, "\"amount\":\"(.*)\",").Groups[1].Value; + string currency = Regex.Match(response, "\"currency\":\"(.*)\",").Groups[1].Value; + string system = Regex.Match(response, "\"system\":\"(.*)\",").Groups[1].Value; + string hash = Regex.Match(response, "\"hash\":\"(.*)\",").Groups[1].Value; + return new string[] { error.ToString(), message, transaction, shop_id, order_id, amount, currency, system, hash }; + } + } +}