Example #1
0
        public async Task <bool> Simular()
        {
            var result = await Ding.SimulateTransfer(new Ding.SendTransferRequest
            {
                SkuCode        = this.Code,
                AccountNumber  = this.numero,
                SendValue      = (float)this.monto,
                DistributorRef = _Global.CurrentAccount.phone1,
                ValidateOnly   = true
            });

            if (result is null)
            {
                this.topupResponse = new topupResponse {
                    error_code = "-1"
                };
                return(true);
            }
            if (result.TransferRecord.ProcessingState == "Complete")
            {
                this.topupResponse = new topupResponse {
                    error_code = "0"
                };
            }
            else
            {
                this.topupResponse = new topupResponse {
                    error_code = "-1"
                };
            }
            return(true);
        }
Example #2
0
        public async Task <bool> Recargar()
        {
            var result = await Ding.SimulateTransfer(new Ding.SendTransferRequest
            {
                SkuCode        = this.Code,
                AccountNumber  = this.numero,
                SendValue      = (float)this.monto,
                DistributorRef = _Global.CurrentAccount.phone1,
                ValidateOnly   = false
            });

            if (result is null)
            {
                this.topupResponse = new topupResponse {
                    error_code = "-1"
                };
                return(true);
            }
            if (result.TransferRecord.ProcessingState == "Complete")
            {
                this.topupResponse = new topupResponse {
                    error_code = "0"
                };
            }
            else
            {
                this.topupResponse = new topupResponse {
                    error_code = "-1"
                };
            }
            return(true);

            //using (var client = new HttpClient())
            //{
            //    client.BaseAddress = new Uri("http://smsteleyuma.azurewebsites.net/Service1.svc/TransferTo/");
            //    client.DefaultRequestHeaders.Accept.Clear();
            //    client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));


            //    var param = new topupInfo()
            //    {
            //        msisdn = "69999999999",
            //        destination_msisdn = this.numero,
            //        product = this.monto.ToString(),
            //        sender_sms = "yes",
            //        action = "topup"
            //    };

            //    var response = await client.PostAsync("topup", param.AsJsonStringContent());
            //    var Result = await response.Content.ReadAsStringAsync();
            //    try
            //    {
            //        this.topupResponse = JsonConvert.DeserializeObject<topupResponse>(Result);
            //        return true;
            //    }
            //    catch
            //    {
            //        return false;
            //    }

            //}
        }