public void PagarPorPix()
        {
            CobrancaRequest cobranca = PreencherCobranca();
            string          txId     = "fc9a4366ff3d4964b5dbc6c91a8722t8";

            string imgBase64 = _baseIntegracao.PagarPorPix(cobranca, txId, PreencherCredenciais());
        }
        public string PagarPorPix(CobrancaRequest cobranca, string txId, Credenciais credenciais)
        {
            string token    = JObject.Parse(Authorize(credenciais))["access_token"].ToString();
            int    location = GerarCobrnca(token, cobranca, txId, credenciais.BaseUrl, credenciais.PathCertificado);

            return(ObterQrCode(token, location, credenciais.BaseUrl, credenciais.PathCertificado));
        }
        public void GerarCobranca()
        {
            CobrancaRequest cobranca    = PreencherCobranca();
            string          txId        = "fc9a4366ff3d4964b5dbc6c91a8722t8";
            string          token       = "eyJhbGciOiJIUzI1NiIsI9.eyJ0eXBlIjoiYWNjZiJDbGllbnRfSWRfOThkMWmNiMWQ0NjM5YWFkOCIsImFjb3VudF9jb2RliNWEyM2I2ZTQ0ZWVkYzU1OTZjY2JhYzFhNjVlYmM3MjgiLCJzY29wZXMiOlsiY29iLnJlYWQiLCJjb2Iud3JpdGUiLCJnbi5iYWxhbmNlLnJlYWQiLCJnbi5waXguZXZwLnJlYWQiLCJnbi5waXguZXZwLndyaXRlIiwiZ24uc2V0dGluZ3MucmVhZCIsImduLnNldHRpbmdzLndyaXRlIiwicGF5bG9hZGxvY2F0aW9uLnJlYWQiLCJwYXlsb2FkbG9jYXRpb24ud3JpdGUiLCJwaXgucmVhZCIsInBpeC53cml0ZSIsIndlYmhvb2sucmVhZCIsIndlYmhvb2sud3JpdGUiXSwiZXhwaXJlc0luIjozNjAwLCJjb25maWd1cmF0aW9uIjp7Ing1dCNTMjU2IjoibnhYYUxXd0hGSGZpdXp2Mk1rck51b2I4T1psSjd4SnNzeitON1gvMGhKRT0ifSwiaWF0IjoxNjIwNzU4NzI0LCJleHAiOjE2MjA3NjIzMjR9.Vk-sW3xPds88vhlW-tItEeOgsQxPRNFXciA6KArOYcI";
            Credenciais     credenciais = PreencherCredenciais();

            _baseIntegracao.GerarCobrnca(token, cobranca, txId, credenciais.BaseUrl, credenciais.PathCertificado);
        }
示例#4
0
        public IActionResult Post([FromBody] CobrancaRequest payLoad, string txId, int credencialId)
        {
            Credenciais credenciais = _baseRepository.ObterCredenciaisGerenciaNet(credencialId);

            payLoad.chave = credenciais.chave;
            string imagem = _baseIntegracao.PagarPorPix(payLoad, txId, credenciais);

            return(Ok(imagem));
        }
        private CobrancaRequest PreencherCobranca()
        {
            CobrancaRequest cobranca = new CobrancaRequest();

            cobranca.calendario.expiracao = 3600;
            cobranca.devedor.cpf          = "12345678901";
            cobranca.devedor.nome         = "Joao Mario";
            cobranca.valor.original       = "1.00";
            cobranca.chave = "15f8g4s7-ec70-4481-95cf-1a2d5e8f55d6";
            cobranca.solicitacaoPagador = "Informe o número ou identificador do pedido.";
            cobranca.infoAdicionais     = new System.Collections.Generic.List <InfoAdicionais>()
            {
                new InfoAdicionais()
                {
                    nome  = "teste",
                    valor = "valorTeste"
                }
            };

            return(cobranca);
        }
        public int GerarCobrnca(string token, CobrancaRequest cobranca, string txId, string baseUrl, string pathCertificado)
        {
            var client = new RestClient(@$ "{baseUrl}/v2/cob/{txId}");

            client.Timeout = -1;
            ObterCertificado(client, pathCertificado);

            var request = new RestRequest(Method.PUT);

            request.AddHeader("authorization", @$ "bearer {token}");
            request.AddHeader("Content-Type", "application/json");
            request.AddHeader("x-client-cert-pem", "{{X-Certificate-Pem}}");
            request.AddParameter("application/json", JsonConvert.SerializeObject(cobranca), ParameterType.RequestBody);
            IRestResponse response = client.Execute(request);

            if (response.StatusCode == System.Net.HttpStatusCode.Created)
            {
                CobrancaResponse location = JsonConvert.DeserializeObject <CobrancaResponse>(response.Content);
                return(location.loc.id);
            }

            return(0);
        }