コード例 #1
0
        public string State()
        {
            if (Session["PaymentPartner"] == null || Session["PaymentId"] == null)
            {
                return("Извините, сервис не доступен");
            }

            string PaymentId = (string)Session["PaymentId"], PaymentPartner = (string)Session["PaymentPartner"];
            var    client = new UniplatProxy.UniplatServiceClient();

            var reqState = new UniplatProxy.ReqState()
            {
                PaymentId = PaymentId, PartnerCode = PaymentPartner
            };

            reqState.Hash = GetHash(reqState.PaymentId + reqState.PartnerCode + password);
            var resp = client.GetDebitState(reqState);

            return(resp.Resultcoment);
        }
コード例 #2
0
        public string Pay(bool chbAccept, string phone2, string phone1, string money, bool captchaValid = true)
        {
            if (chbAccept)
            {
                return("Для продолжения необходимо принять условия предоставления услуг");
            }

            //if (!captchaValid)
            //    return "Введен неверный код с картинки";

            string phone = phone2;

            phone = Regex.Replace(phone, "[^0-9]", String.Empty);
            if (phone.Length < 10)
            {
                return("Введен неверный номер телефона");
            }

            int  def   = int.Parse(phone.Substring(0, 3));
            long range = long.Parse(phone.Substring(3));

            //var operatorBrands = from myRow in DefCodes.AsEnumerable()
            //                     where
            //                         myRow.Field<int>("DEF") == def
            //                         && myRow.Field<long>("RangeStart") <= range
            //                         && myRow.Field<long>("RangeEnd") >= range
            //                     select myRow.Field<Guid>("OperatorBrandId");

            //if (!operatorBrands.Any())
            //    return "Неизвестный телефонный оператор";

            long moneyCount;

            if (!long.TryParse(money, out moneyCount))
            {
                return("Введена неверная сумма");
            }

            //переводим рубли в копейки
            moneyCount  = (long)CountMoney((int)moneyCount);
            moneyCount *= 100;

            //var payment = new ClPayment();
            //if (payment.SendPaymentToMobicom(phone, moneyCount, operatorBrands.First()) == 0)



            var client = new UniplatProxy.UniplatServiceClient(); // .UniplatService();
            {
                Console.WriteLine("Sending DebitMoney");
                var paymentNumber = DateTime.Now.Ticks.ToString().Substring(1, 10);
                var req           = new UniplatProxy.ReqDebit()
                {
                    Amount        = (int)moneyCount, //1000,
                    Comment       = "Ваше такси",
                    PartnerCode   = "tst",
                    ServiceId     = "6889",
                    MSISDN        = phone, //"9099952793", //"9035618208", //"9168036435",//"9099952793",//"9055812453",
                    PaymentNumber = paymentNumber,
                    PaymentId     = Guid.NewGuid().ToString()
                };



                req.Hash = GetHash(req.PaymentId + req.PartnerCode + req.ServiceId + req.MSISDN + req.PaymentNumber +
                                   req.Amount + password);
                var resp = client.DebitMoney(req);


                if (resp.ResultCode == 0)
                {
                    Session["PaymentPartner"] = req.PartnerCode;
                    Session["PaymentId"]      = req.PaymentId;
                    return("Ваша заявка принята");

                    #region comment
                    //Console.WriteLine("Succsessfull response received");
                    //Console.WriteLine("Send state request?");
                    //int x = 0;
                    //while (Console.ReadLine() == "y") //(x ++ < 10)
                    //{
                    //    var reqState = new UniplatServiceWCF.ReqState() {PaymentId = req.PaymentId, PartnerCode = "tst"};
                    //    reqState.Hash = GetHash(reqState.PaymentId + reqState.PartnerCode + password);
                    //    resp = client.GetDebitState(reqState);
                    //    Console.WriteLine(resp.ResultCode + " " + resp.Resultcoment);
                    //}
                    #endregion
                }
                else
                {
                    return("Извините, сервис временно недоступен");
                }
            }
        }