示例#1
0
        public async Task <Ding.SendTransferResponse> DingSimular(object cuenta)
        {
            var phone1 = "";


            if (cuenta is customer_info)
            {
                var customer = cuenta as customer_info;
                phone1 = customer.phone1;
            }
            else
            if (cuenta is account_info)
            {
                var account = cuenta as account_info;
                phone1 = account.phone1;
            }


            var reguest = new Ding.SendTransferRequest
            {
                AccountNumber  = this.CodigoPais + this.Numero,
                SkuCode        = "CU_NU_TopUp",
                SendValue      = this.Monto,
                ValidateOnly   = true,
                DistributorRef = phone1
            };

            return(await Ding.SendTransfer(reguest));
        }
示例#2
0
        //public async Task<bool> Simular(string pnone1)
        //{

        //    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 = pnone1,
        //            destination_msisdn = this.CodigoPais + this.Numero,
        //            product = this.Monto.ToString(),
        //            sender_sms = "yes",
        //            action = "simulation"
        //        };

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

        //    }
        //}

        //public async Task<bool> recargar(string pnone1)
        //{

        //    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 = pnone1,
        //            destination_msisdn = this.CodigoPais + 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
        //        {
        //            topupMovil.topupResponse = JsonConvert.DeserializeObject<topupResponse>(Result);
        //            return true;
        //        }
        //        catch
        //        {
        //            return false;
        //        }

        //    }
        //}


        public async Task <Ding.SendTransferResponse> DingSimular(string phone1)
        {
            var reguest = new Ding.SendTransferRequest {
                AccountNumber  = this.CodigoPais + this.Numero,
                SkuCode        = "CU_CU_TopUp",
                SendValue      = this.Monto,
                ValidateOnly   = true,
                DistributorRef = phone1
            };

            return(await Ding.SendTransfer(reguest));
        }
        // POST: api/TopUp
        public async Task <IHttpActionResult> Post([FromBody] Teleyuma.Teleyuma.TopUpRequest topUpRequest)
        {
            if (Autorize.TeleyumaLogin(this.Request.Headers).ErrorCode > 0)
            {
                return(CreatedAtRoute("DefaultApi", null, Autorize.TeleyumaLogin(this.Request.Headers)));
            }

            //Transformar datos

            var DingRequest = new Ding.SendTransferRequest();

            DingRequest.SkuCode        = topUpRequest.SkuCode;
            DingRequest.AccountNumber  = topUpRequest.AccountNumber;
            DingRequest.SendValue      = topUpRequest.SendValue;
            DingRequest.DistributorRef = topUpRequest.DistributorRef;
            DingRequest.ValidateOnly   = topUpRequest.ValidateOnly;

            var result = await Ding.SendTransfer(DingRequest);

            return(CreatedAtRoute("DefaultApi", null, result));
        }