Ejemplo n.º 1
0
 public static string AddTransaction(int sum, User user, ref string billId)
 {
     try
     {
         var response = client.CreateBill(
             info: new CreateBillInfo
         {
             BillId = Guid.NewGuid().ToString(),
             Amount = new MoneyAmount
             {
                 ValueDecimal = sum,
                 CurrencyEnum = CurrencyEnum.Rub
             },
             ExpirationDateTime = DateTime.Now.AddDays(5),
             Customer           = new Customer
             {
                 Account = user.Id.ToString()
             }
         });
         billId = response.BillId;
         return(response.PayUrl.ToString());
     }
     catch
     {
         return(null);
     }
 }
Ejemplo n.º 2
0
    // ПОПРОБЫВАТЬ ЧЕРЕЗ МНОГОПОТОЧНОСТЬ ПРОВЕРЯТЬ СОСТОЯНИЕ ОБЪЕКТА НА СЕРВЕРЕ

    public void CheckStatus()
    {
        var form = client.CreateBill(
            info: new CreateBillInfo
        {
            BillId = Guid.NewGuid().ToString(),
            Amount = new MoneyAmount
            {
                ValueDecimal = 1.0m,
                CurrencyEnum = CurrencyEnum.Rub
            },
            Comment            = "Оплата вещи из игры",
            ExpirationDateTime = DateTime.Now.AddDays(45),
            Customer           = new Customer
            {
                Email   = "*****@*****.**",
                Account = Guid.NewGuid().ToString(),
                Phone   = "792751287912"
            },
        }
            );

        Process.Start(form.PayUrl.ToString());

        string status = "";

        while (true)
        {
            if (form.Status.ValueString == "PAID")
            {
                status = form.Status.ValueString;
                break;
            }
        }
    }
Ejemplo n.º 3
0
    // создаю форму о для покупки предмета
    private void CheckStatus()
    {
        pay = Convert.ToDecimal(payment);
        BillPaymentsClient client = BillPaymentsClientFactory.Create(
            secretKey: "eyJ2ZXJzaW9uIjoiUDJQIiwiZGF0YSI6eyJwYXlpbl9tZXJjaGFudF9zaXRlX3VpZCI6IjU5Z29icC0wMCIsInVzZXJfaWQiOiI3OTI3NDI1NTQ1MCIsInNlY3JldCI6ImZiZmM1YmQ4NDViYTU0YTlhNmZmYmNlMzQ4OTQ3Mzc3OTk0ZThiN2FhNDg5YjZjYTk0ODU1NjRkNzkxNTA1MjUifX0="
            );

        var form = client.CreateBill(
            info: new CreateBillInfo
        {
            BillId = Guid.NewGuid().ToString(),
            Amount = new MoneyAmount
            {
                ValueDecimal = pay,
                CurrencyEnum = CurrencyEnum.Rub
            },
            Comment            = textNameItem.text,
            ExpirationDateTime = DateTime.Now.AddDays(45),
            Customer           = new Customer
            {
                Email   = "*****@*****.**",
                Account = Guid.NewGuid().ToString(),
                Phone   = "792751287912"
            },
        }
            );

        print(form.PayUrl.ToString());
        Process.Start(form.PayUrl.ToString());
        //using (StreamWriter sw = new StreamWriter(Application.streamingAssetsPath + "/Report.txt", true, System.Text.Encoding.Default))
        //{
        //    sw.Write(textNameItem.text);
        //}

        string status = "";

        while (true)
        {
            var responseStatus = client.GetBillInfo(billId: form.BillId);
            if (responseStatus.Status.ValueString == "PAID")
            {
                //if (status == "PAID")
                //{
                // получаю путь к txt
                string path = Application.streamingAssetsPath + "/Report.txt";

                using (StreamWriter sw = new StreamWriter(path, true, System.Text.Encoding.Default))
                {
                    sw.Write(textNameItem.text);
                }
                //}
                status = form.Status.ValueString;
                break;
            }
        }
    }
Ejemplo n.º 4
0
        public async Task <string> Method(int IdPeop, string FirstName, string LastName, string[] AccId)
        {
            var client     = new MongoClient("mongodb://localhost");
            var database   = client.GetDatabase("GamesAcc");
            var collection = database.GetCollection <PaymentsModel>("Payments");

            MainWork costAcc = new MainWork();
            decimal  price   = costAcc.CostsID(Program.id).GetAwaiter().GetResult();

            //Qiwi.BillPayments.Model.Out.BillResponse
            var newPayment = clientQiwi.CreateBill(
                info: new CreateBillInfo
            {
                BillId = Guid.NewGuid().ToString(),
                Amount = new MoneyAmount
                {
                    ValueDecimal = price,
                    CurrencyEnum = CurrencyEnum.Rub
                },
                Comment            = "comment",
                ExpirationDateTime = DateTime.Now.AddDays(45),
                Customer           = new Customer
                {
                    Email   = "*****@*****.**",
                    Account = Guid.NewGuid().ToString(),
                    Phone   = "79265064230"
                }
            },
                customFields: new CustomFields
            {
                ThemeCode = "кодСтиля"
            }
                );

            BDwithPay.UserBillId = newPayment.BillId.ToString();
            //var infopayment = clientQiwi.GetBillInfo(newPayment.BillId);
            var model = new PaymentsModel {
                Id = ObjectId.GenerateNewId(), FirstName = FirstName, LastName = LastName, IDPeop = IdPeop, Url = newPayment.PayUrl.ToString(), Status = newPayment.Status.ValueString.ToString(), BillId = newPayment.BillId.ToString(), BuyAcc = AccId
            };
            await collection.InsertOneAsync(model);

            string url = newPayment.PayUrl.ToString();

            return(url);
        }
Ejemplo n.º 5
0
        public Uri CreatePaymentURL(int chatId, string username)
        {
            decimal      sum      = chatId != 526655661 ? 35.0m : 1.0m;
            BillResponse response = qiwiClient.CreateBill(
                new CreateBillInfo
            {
                BillId = Guid.NewGuid().ToString(),
                Amount = new MoneyAmount
                {
                    ValueDecimal = sum,
                    CurrencyEnum = CurrencyEnum.Rub
                },
                Comment            = $"{chatId}|{username}",
                ExpirationDateTime = DateTime.Now.AddHours(1)
            }
                );

            return(response.PayUrl);
        }
Ejemplo n.º 6
0
        public string Pay(User user, Purchase purchase)
        {
            BillPaymentsClient client = BillPaymentsClientFactory.Create(secretKey: "eyJ2ZXJzaW9uIjoiUDJQIiwiZGF0YSI6eyJwYXlpbl9tZXJjaGFudF9zaXRlX3VpZCI6InNkbmNjaC0wMCIsInVzZXJfaWQiOiI3NzAxMzk4OTM5NiIsInNlY3JldCI6ImVjMDc5Y2RlNmYwNTMzZTMyNDM1MzFkMDQ0ZmJhNzM2NTc0ZWI2NWZkNDUzZmUzYWViNTFmMzUzNzI1MjNhNDQifX0=");


            BillResponse form = client.CreateBill(
                info: new CreateBillInfo
            {
                BillId = Guid.NewGuid().ToString(),
                Amount = new MoneyAmount
                {
                    ValueDecimal = 1.0m,
                    CurrencyEnum = CurrencyEnum.Kzt
                },
                Comment            = "Сумма счета",
                ExpirationDateTime = DateTime.Now.AddDays(2),
                Customer           = new Customer
                {
                    Email   = user.Email,
                    Account = Guid.NewGuid().ToString(),
                    Phone   = user.Phone
                },
            }
                );

            BillResponse responseStatus = client.GetBillInfo(billId: form.BillId);
            string       status         = responseStatus.Status.ValueString;

            Process myProcess = new Process();

            myProcess.StartInfo.UseShellExecute = true;
            myProcess.StartInfo.FileName        = responseStatus.PayUrl.AbsoluteUri;
            myProcess.Start();


            int timer      = 0;
            int timeForPay = 100000;
            int oneSecond  = 1000;

            while (true)
            {
                try
                {
                    responseStatus = client.GetBillInfo(billId: form.BillId);
                    status         = responseStatus.Status.ValueString;
                }
                catch
                {
                    status = Status.WAITING.ToString();
                }
                if (timer == timeForPay)
                {
                    status = Status.REJECTED.ToString();
                }
                Console.WriteLine(timer);
                Thread.Sleep(oneSecond * 5);
                timer += oneSecond * 5;
                if (status == Status.PAID.ToString())
                {
                    return(status);
                }
                else if (status == Status.REJECTED.ToString())
                {
                    client.CancelBill(billId: form.BillId);
                    return(status);
                }
            }
        }
Ejemplo n.º 7
0
        public bool ToPay(decimal MoneyAmount)
        {
            //MoneyAmount заменяется на 1 тенге
            MoneyAmount = 1;

            //Секретный ключ отправителя счета
            const string ownerSecretKey       = "eyJ2ZXJzaW9uIjoiUDJQIiwiZGF0YSI6eyJwYXlpbl9tZXJjaGFudF9zaXRlX3VpZCI6InNkbmNjaC0wMCIsInVzZXJfaWQiOiI3NzAxMzk4OTM5NiIsInNlY3JldCI6ImVjMDc5Y2RlNmYwNTMzZTMyNDM1MzFkMDQ0ZmJhNzM2NTc0ZWI2NWZkNDUzZmUzYWViNTFmMzUzNzI1MjNhNDQifX0=";
            const int    second               = 1000; //Одна секунда равняется 1000 мл.секунд
            const int    updateTime           = 10;   //Время для обновления статуса оплаты
            const int    numberDaysForPayment = 5;    //Количество дней для оплаты счета
            string       currentStatus;               //Текущий статус оплаты
            int          numberLoops = 15;

            BillPaymentsClient qiwiClient = BillPaymentsClientFactory.Create(secretKey: ownerSecretKey);


            BillResponse qiwiResponse = qiwiClient.CreateBill(
                info: new CreateBillInfo
            {
                BillId = Guid.NewGuid().ToString(),
                Amount = new MoneyAmount
                {
                    ValueDecimal = MoneyAmount,
                    CurrencyEnum = CurrencyEnum.Kzt
                },
                ExpirationDateTime = DateTime.Now.AddDays(numberDaysForPayment),
            }
                );

            BillResponse response = qiwiClient.GetBillInfo(billId: qiwiResponse.BillId);

            //Открыть URL в браузере
            Process process = new Process();

            process.StartInfo.UseShellExecute = true;
            process.StartInfo.FileName        = response.PayUrl.AbsoluteUri;
            process.Start();


            int counter = new int();

            while (true)
            {
                if (counter == numberLoops)
                {
                    return(false);
                }

                try
                {
                    currentStatus = qiwiClient.GetBillInfo(billId: qiwiResponse.BillId).Status.ValueString;
                }
                catch
                {
                    currentStatus = "WAITING";
                }
                Thread.Sleep(second * updateTime);
                Console.Clear();

                switch (currentStatus)
                {
                case "PAID":
                    return(true);

                case "REJECTED":
                    return(false);

                case "WAITING":
                    continue;
                }

                counter++;
            }
        }