public async Task <MyJsonResult> PagSeguroPayment()
        {
            var user             = _UserRepo.GetByEmail(User.Identity.Name);
            var config           = _ServerConfigRepo.GetAllConfig();
            var tokenPagament    = Guid.NewGuid().ToString();
            var PagamentoLicenca = new PagamentoLicenca()
            {
                Usuario_Id               = user.Id,
                DataCriacaoInvoice       = DateTime.UtcNow,
                MetodoPagamentoId        = 1,
                PagamentoLicencaStatusId = 1,
                ValoraReceber            = config.PrecoLicenca,
                TokenPagamento           = tokenPagament
            };

            _PagamentoRepo.Add(PagamentoLicenca);

            var apiPagSeguro = new ApiPagSeguro(config.PagseguroToken, config.AppServer, PagseguroisSandbox);
            var response     = apiPagSeguro.GeneratePayment(PagamentoLicenca.Id, config.PrecoLicenca);

            if (response.IsSuccessStatusCode)
            {
                var result = await response.Content.ReadAsStringAsync();

                var xmlSerializer = new XmlSerializer(typeof(checkout));
                using (var textReader = new StringReader(result))
                {
                    var objret = (checkout)xmlSerializer.Deserialize(textReader);
                    return(new MyJsonResult(apiPagSeguro.pagseguroUrl + objret.code, JsonRequestBehavior.AllowGet));
                }
            }
            Response.TrySkipIisCustomErrors = true;
            Response.StatusCode             = 400;
            return(new MyJsonResult("Erro no metodo de Pagamento", JsonRequestBehavior.AllowGet));
        }
        public MyJsonResult BitpayPayment()
        {
            var user             = _UserRepo.GetByEmail(User.Identity.Name);
            var config           = _ServerConfigRepo.GetAllConfig();
            var tokenPagament    = Guid.NewGuid().ToString();
            var PagamentoLicenca = new PagamentoLicenca()
            {
                Usuario_Id               = user.Id,
                DataCriacaoInvoice       = DateTime.UtcNow,
                MetodoPagamentoId        = 2,
                PagamentoLicencaStatusId = 1,
                ValoraReceber            = config.PrecoLicenca,
                TokenPagamento           = tokenPagament
            };

            _PagamentoRepo.Add(PagamentoLicenca);

            ApiBitPay bitpay    = new ApiBitPay(config.BitpayToken, config.BitpayIdentity, bitpayisSandbox);
            var       pagamento = bitpay.GeneratePayment(user, PagamentoLicenca.Id, config.PrecoLicenca, tokenPagament);

            if (pagamento.IsSuccessStatusCode)
            {
                var content = pagamento.Content.ReadAsStringAsync().Result;
                var obj     = JsonConvert.DeserializeObject <BitpaiInvoiceResponse>(content);
                return(new MyJsonResult(obj.data.Url, JsonRequestBehavior.AllowGet));
            }
            else
            {
                Response.TrySkipIisCustomErrors = true;
                Response.StatusCode             = 400;
                Response.StatusDescription      = "Erro no metodo de Pagamento";
                return(new MyJsonResult("Erro no metodo de Pagamento", JsonRequestBehavior.AllowGet));
            }
        }