Ir para conteúdo
  • Cadastre-se

Jhonlenon Ribeiro

Membros
  • Total de ítens

    621
  • Registro em

  • Última visita

  • Days Won

    5

Tudo que Jhonlenon Ribeiro postou

  1. Juliomar Marchetti Eu fiz usando o indy..meu problema é que tem algumas partes dos fontes da ACBr que não entendo...outro detalhe que ajudaria bastante era se o componente ACBrboleto tivesse a opçao de enviar o certificado digital na requisição...BB, Caixa e Sicredi não precisa do envio do certificado digital na requisição....mais os bancos como santander, itaú, sicoob, Bradescoe Inter precisa do certificado digital na requisição.
  2. Será que já tem o boleto híbrido do PIX do itaú? eu não achei nada sobre isso....apenas o PIX normal.
  3. flexmobile Eu vou tentar fazer o boleto híbrido do itaú agora...já fizemos o boleto tradicional na v2 do itaú...vou conversar com meu gerente de conta para abrir um protocolo para homologação do boleto híbrido PIX itáu. Eu já tem os boletos híbrido sicredi, sicoob e BB.
  4. Italo Giurizzato Junior Obrigado...eu copiei o aquivo TabServicos.txt e coloquei dentro da pasta da minha aplicação...veleu mesmo pela ajuda....pode encerrar o topico.
  5. Italo Giurizzato Junior Dá uma olhada nesses 2 prints em anexo...ambos foram gerado pelo componente ACBrNFSeX e usando o fortes report. O que muda são os provedores de serviço que são diferentes....mais no XML de ambos retorna a tag ItemListaServico e CodigoCnae preenchido. https://mega.nz/file/P0RXmQiI#twjW4lTkVt021a4KxhO7uVbxNAQ0w3EChpzhV1RtNv8 https://mega.nz/file/it5jSQaZ#rr_gTJzKluHc8XGUexXsJZ2fXb3CxmlATbPOMtc9ttU
  6. Italo Giurizzato Junior Boa tarde...pois é tem uns clientes que não aceitou o PDF da DANFSE gerado pelo componente..ai tive que pegar a segunda via no site da prefeitura. Não teria como colocar essa código cnae prasair no DANFSE?
  7. Bom dia, na minha impressão do DANFSE da Nota Fiscal de Serviço no componente ACBrNFSeX não está aparecendo o Código CNAE do serviço, tem alguma propriedade que deve marcar pra sair? O provedor que estou usando é Webiss. está tudo OK no site da prefeitura...porque se pego uma segunda via pelo site sai o codigo do CNAE do serviço. Mais na minha impressão não. Obs: eu estou usando fortes report na impressão.
  8. Bom dia...em nosso sistema conseguimos emitir boleto hibrido (PIX) em homologação e produção...mais não usei ACBrboleto...eu fiz pelo indy
  9. Só mais um detalhe..nessa nova API de Boleto do Sicredi você pode usar o boleto código de barra tradicional ou o boleto híbrido que seria o boleto PIX.
  10. marcelo.hgv Bom dia amigo, hoje o sicredi tem 2 modelo de API de Emissão de boleto. 1) - Primeira API de Cobrança do Sicredi, onde o cooperado precisa ter o serviço ECOMM API ativado na sua conta, e também tem que gerar o código de acesso do internet bank do sicredi. Obs: nessa API não tem ambiente de homologação, tudo é em produção. 2) - Segunda API de Cobrança do Sicredi, onde o cooperado precisa ter o serviço ECOMM API ativado na sua conta, e também tem que gerar o código de acesso do internet bank do sicredi e access token obtido no portal do developers do sicred. Obs: nessa API tem o ambiente de homologação (Sandbox) e ambiente de produção, existe o access token em homologação e em produção. Hoje ACBr, tem a primeira API de cobrança do sicredi, mais não é dificil de implementar essa nova api também aos fontes. Vou deixar o manual da 2 API aqui. Pois eu já desenvolvi as 2 https://mega.nz/file/ChYmwZAA#1r6tzI20wVjVZEYRSnJCzLnbNEmwhJB59GuCNdUoolI https://mega.nz/file/bwAglbgZ#STEX53GyngyPd1W-OGtKZaVSUWs5xNXAcWhtW-qlnFQ
  11. Italo Giurizzato Junior Boa tarde, eu não estava entendo que o componente pegava da propria chave de acesso do documento anterior...foi um vacilo meu...pode encerrar o topico e muito obrigado pela atenção.
  12. Boa tarde, alguém sabe como faço pra mudar o numero de serie nos dados do CT-e Anterior de um CT-e com tipo de serviço de Subcontratação....me parece que por padrão já joga o mesmo numero de serie do CT-e emitido. veja o print em anexo.
  13. luisclaudio_jr era isso mesmo..um CT-e de Subcontratação....obrigado....pode encerrar o topico
  14. Bom dia, um cliente meu solicitou a emissão de um CT-e com esse termo. Contra Manifesto de CT-e alguém já emitiu algum CT-e desse jeito? to perdido...nunca vi falar nesse termo.
  15. Estou com dúvida, um cliente me quescionou sobre o RNTRC que sai no reboque....ele falou em um unico veiculo pode ter mais um RNTRC e o DAMDFe do MDF-e sai repetido, todos igual ao primeiro, vi que no XML só tem uma unica tag do RNTRC. Será que existe mesmo mais de um RNTRC em um unico veiculo? anexei um print
  16. Gustavo Totta Eu não sei se vai te ajudar amigo...mais com emissão de boleto do alios via API eu salvo a LINHA DIGITAVÉL e CODIGO DE BARRAS que vem no retorno da API no banco de dados e alimento arquivo.fr3 no boleto com LINHA DIGITAVÉL e CODIGO DE BARRAS...nosso fiz uma arquivo de boleto.fr3 modificado para Alios...tive que fazer isso para o Alios e inter....os demais bancos deu certo a linha digitavél e codigo de barras.
  17. Gustavo Totta Bom dia...me chama no PV pra ver se consigo te ajudar
  18. flexmobile Está no portal do developers..infelizmente não posso postar algumas informações sobre a API do Itaú, quando somos cadastrado no portal do developers existe um contrato que falo sobre publicar informações interna sobre a API. Acessa o portal developers que está tudo lá...qualquer coisa me chama no privado.
  19. Vou deixar minha procedure de emissão de boleto usando API de Cobrança v2 em anexo. O mais importante é entender o processo que o site developers orienta. A ajuda dos gerente de conta é fundamental, mesmo que eles não entenda praticamente nada sobre o processo, porque quem abre a ocorrência para implantar a API de Cobrança é o gerente de conta PJ do itaú. Procedure Emissão Boleto Itau v2.txt
  20. Coletek MG Eu consegui fazer a baixar....agora está 100%...Emissão, Consulta e Baixa na API Cobranca v2. O erro 403 Forbidden na consulta é permissão no seu token, nesse caso vc tem que reportar ao suporte do itaú para dá permissão no seu token.
  21. Coletek MG Boa noite, vc poderia postar aqui como vc fez a baixa do boleto itaú? eu estou conseguindo emitir e consultar, mais estou perdido na baixa do boleto.
  22. Boa tarde, esse é meu códgio para obter o token bearer e emissão de boleto na API v2 do itaú, feito com indy. Implementação concluida com sucesso.API de Cobrança v2 Itaú. uses IdHTTP, IdIOHandlerStack, IdSSL, blcksock, System.Json, IdGlobalProtocols, IdSSLOpenSSL, synautil, synsock, ssl_openssl; procedure TF_boleto.EnviarBoletoItau; var mURL, sResponse, mCode : string; HTTP, HttpClient: TIdHTTP; FParams, access_token, refresh_token : String; Json, scope, token_type, expires_in, RESULTADO_BOLETO : String; JsontoSend, AResponseContent : TStringStream; var IOHandler : TIdSSLIOHandlerSocketOpenSSL; var Resp, Req, Resp_Cobranca, Req_Cobranca: TStringStream; var Result, s, recieveID, DATA_EMISSAO, DATA_VENCIMENTO, ArquivoJSON, ACESSO_TOKEN, RESULTADO_TOKEN, valorTexto : String; var TICKET_XML, XML_COBRANCA : TStringList; var newFile, Arq_Liberacao : TextFile; var TICKET, RET_CODE, TIPO_PESSOA, TIPO_AMBIENTE, NSU, sCAMINHGO_EXE, FURLToken, URL, NUMERO_CADASTRO_PESSOA, JSON_TOKEN, JSON_BOLETO : String; var DIAS_MULTA, DATA_HORA_TOKEN : Integer; XMLResponse, TIPO_VALIDACAO, ID_BENEFICIARIO, VALOR_BOLETO, TIPO_CLIENTE, VALOR_JUROS, VALOR_MULTAS, TextoOriginal : String; var JsonStreamRetorno, JsonStreamEnvio: TStringStream; SSL : TIdSSLIOHandlerSocketOpenSSL; begin //-----Todo conhecimento que o homem possui é dada por DEUS------------------- if Length(DM.SQL_contas_receber_boletoCPF_CNPJ_Cliente.AsString) = 14 then begin TIPO_CLIENTE := 'J'; NUMERO_CADASTRO_PESSOA := 'numero_cadastro_nacional_pessoa_juridica'; end else begin TIPO_CLIENTE := 'F'; NUMERO_CADASTRO_PESSOA := 'numero_cadastro_pessoa_fisica'; end; DATA_EMISSAO :=PegarNumeros(DateToStr(DM.SQL_contas_receber_boletoDetalhe_Data_Emissao.AsDateTime)); DATA_VENCIMENTO :=PegarNumeros(DateToStr(DM.SQL_contas_receber_boletoDetalhe_Data_Vencimento.AsDateTime)); TIPO_VALIDACAO :=''; if DM.TIPO_AMBIENTE_BOLETO = 'Homologação' then begin TIPO_VALIDACAO :='validacao'; end else begin TIPO_VALIDACAO :='efetivacao'; end; DATA_EMISSAO :=Copy(DATA_EMISSAO, 5, 4)+ '-'+ Copy(DATA_EMISSAO, 3, 2)+ '-'+Copy(DATA_EMISSAO, 1, 2); DATA_VENCIMENTO :=Copy(DATA_VENCIMENTO , 5, 4)+ '-'+ Copy(DATA_VENCIMENTO , 3, 2)+ '-'+Copy(DATA_VENCIMENTO , 1, 2); ID_BENEFICIARIO :=''; ID_BENEFICIARIO :=DM.SQL_busca_contaEmpresa_Agencia.AsString + FormatFloat('0000000', DM.SQL_busca_contaEmpresa_conta.AsInteger) + DM.SQL_busca_contaEmpresa_Conta_Digito.AsString; VALOR_BOLETO :=''; VALOR_BOLETO :=PegarNumeros(FormatFloat('#000000000000000.00', DM.SQL_contas_receber_boletoDetalhe_Valor_Falta.AsFloat)); VALOR_MULTAS :=PegarNumeros(FormatFloat('#000000000000000.00', roundabnt(DM.SQL_busca_contaMULTA_DIA.AsFloat,-2))); VALOR_JUROS :=PegarNumeros(FormatFloat('#000000000000000.00', roundabnt(VALOR_MOURA_JUROS,-2))); JSON_BOLETO :='{' + #13 + ' "data": {' + #13 + ' "etapa_processo_boleto": "'+TIPO_VALIDACAO+'",' + #13 + ' "codigo_canal_operacao": "API",' + #13 + ' "beneficiario": {' + #13 + ' "id_beneficiario": "'+ID_BENEFICIARIO+'"' + #13 + ' },' + #13 + ' "dado_boleto": {' + #13 + ' "descricao_instrumento_cobranca": "boleto",' + #13 + ' "tipo_boleto": "a vista",' + #13 + ' "codigo_carteira": "'+DM.SQL_busca_contaCarteira.AsString +'",' + #13 + ' "valor_total_titulo": "'+VALOR_BOLETO+'",' + #13 + ' "codigo_especie": "01",' + #13 + ' "valor_abatimento": "000",' + #13 + ' "data_emissao": "'+DATA_EMISSAO+'",' + #13 + ' "indicador_pagamento_parcial": false,' + #13 + ' "quantidade_maximo_parcial": 0,' + #13 + ' "pagador": {' + #13 + ' "pessoa": {' + #13 + ' "nome_pessoa": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoNomeRazaoSocial.AsString, 1, 50)))+'",' + #13 + ' "tipo_pessoa": {' + #13 + ' "codigo_tipo_pessoa": "'+TIPO_CLIENTE+'",' + #13 + ' "'+NUMERO_CADASTRO_PESSOA+'": "'+DM.SQL_contas_receber_boletoCPF_CNPJ_Cliente.AsString+'"' + #13 + ' }' + #13 + ' },' + #13 + ' "endereco": {' + #13 + ' "nome_logradouro": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoEndereco.AsString, 1, 40)))+ ', '+Copy(DM.SQL_contas_receber_boletoNumero.AsString, 1, 5)+'",' + #13 + ' "nome_bairro": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoBairro.AsString, 1, 40)))+'",' + #13 + ' "nome_cidade": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoCidade.AsString, 1, 40)))+'",' + #13 + ' "sigla_UF": "'+DM.SQL_contas_receber_boletoUF.AsString+'",' + #13 + ' "numero_CEP": "'+DM.SQL_contas_receber_boletoCEP.AsString+'"' + #13 + ' }' + #13 + ' },' + #13 + ' "dados_individuais_boleto": [{' + #13 + ' "numero_nosso_numero": "'+sNOSSO_NUMERO_ITAU+'",' + #13 + ' "data_vencimento": "'+DATA_VENCIMENTO+'",' + #13 + ' "valor_titulo": "'+VALOR_BOLETO+'",' + #13 + ' "texto_uso_beneficiario": "'+DM.SQL_contas_receber_boletoDetalhe_N_Parcela.AsString+'",' + #13 + ' "texto_seu_numero": "'+DM.SQL_contas_receber_boletoDetalhe_N_Documento.AsString+'"' + #13 + ' }],' + #13 + ' "multa": {' + #13 + ' "codigo_tipo_multa": "02",' + #13 + ' "quantidade_dias_multa": 1,' + #13 + ' "percentual_multa": "'+VALOR_MULTAS+'"' + #13 + ' },' + #13 + ' "juros": {' + #13 + ' "codigo_tipo_juros": 93,' + #13 + ' "quantidade_dias_juros": 1,' + #13 + ' "valor_juros": "'+VALOR_JUROS+'"' + #13 + ' },' + #13 + ' "recebimento_divergente": {' + #13 + ' "codigo_tipo_autorizacao": "03"' + #13 + ' },' + #13 + // ' "instrucao_cobranca": [' + #13 + // ' {' + #13 + // ' "codigo_instrucao_cobranca": "4",' + #13 + // ' "quantidade_dias_apos_vencimento":60,' + #13 + // ' "dia_util":false' + #13 + // ' } ' + #13 + // ' ], ' + #13 + ' "protesto": {' + #13 + ' "protesto": 4,' + #13 + ' "quantidade_dias_protesto": 1' + #13 + ' },' + #13 + ' "negativacao": { ' + #13 + ' "negativacao": 5, ' + #13 + ' "quantidade_dias_negativacao": 1 ' + #13 + ' }, ' + #13 + ' ' + #13 + ' "desconto_expresso": false' + #13 + ' }' + #13 + ' }' + #13 + '}'; ArquivoJSON := ''; ArquivoJSON := JSON_BOLETO; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim('Registro _Itau_'+sNOSSO_NUMERO_ITAU) + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); RESULTADO_TOKEN :=''; access_token :=''; JSON_TOKEN := 'grant_type=client_credentials&client_id='+ DM.SQL_busca_contaClientID.AsString+'&client_secret='+DM.SQL_busca_contaClientSecret.AsString; try HttpClient := TIdHTTP.Create( nil ); SSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil); HttpClient.IOHandler := SSL; JsonStreamEnvio := TStringStream.Create(utf8Encode(JSON_TOKEN)); DATA_HORA_TOKEN :=DM.conecta.ExecSQLScalar('SELECT IFNULL(TIMESTAMPDIFF (MINUTE,Data_access_token,NOW()),8) AS QTD_Horas FROM configuracao_boleto where Codigo_Config_Boleto =:BANCO and CodLoja_Boleto =:COD_LOJA', [DM.COD_BANCO, DM.COD_LOJA]); if DATA_HORA_TOKEN >= 4 then begin with SSL.SSLOptions do begin CertFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CERTIFICADO.crt'; KeyFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CHAVE_PRIVADA.key'; Mode := sslmUnassigned; Method := sslvSSLv23; SSLVersions := [sslvSSLv23]; end; URL :='essa url está no portal do developers itau'; with HttpClient do begin Request.CharSet := 'utf-8'; Request.Accept := '*/*'; Request.AcceptEncoding := 'gzip, deflate, br'; Request.CustomHeaders.Values['Content-Type'] := 'application/x-www-form-urlencoded'; Request.CustomHeaders.Values['x-itau-flowID'] := DM.SQL_busca_contaClientID.AsString + 'd7'; Request.CustomHeaders.Values['x-itau-correlationID'] := DM.SQL_busca_contaClientSecret.AsString; Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Maxthon; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)'; HandleRedirects := True; HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth]; end; try RESULTADO_TOKEN := HttpClient.Post(URL,JsonStreamEnvio); Except on E: Exception do begin ERRO_ITTAU :='SIM'; RESULTADO_TOKEN :=HttpClient.ResponseText; ArquivoJSON :=''; ArquivoJSON := RESULTADO_TOKEN; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end; end; if HttpClient.ResponseCode = 200 then begin access_token :=''; expires_in :=''; access_token :=getCamposJsonString(RESULTADO_TOKEN, 'access_token'); expires_in :=getCamposJsonString(RESULTADO_TOKEN, 'expires_in'); scope :=getCamposJsonString(RESULTADO_TOKEN, 'scope'); DM.conecta.ExecSQL('update configuracao_boleto set access_token =:TOKEN, Scope =:SCOPE, expires_in =:EXPIRA, Data_access_token =NOW() where Codigo_Config_Boleto =:BANCO and CodLoja_Boleto =:COD_LOJA', [access_token, scope, StrToInt(expires_in), DM.COD_BANCO, DM.COD_LOJA]); end else begin ERRO_ITTAU :='SIM'; ArquivoJSON :=''; ArquivoJSON := RESULTADO_TOKEN; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end; end else begin access_token :=''; access_token :=DM.conecta.ExecSQLScalar('select IFNULL(access_token, "") AS token from configuracao_boleto where Codigo_Config_Boleto =:BANCO and CodLoja_Boleto =:COD_LOJA', [DM.COD_BANCO, DM.COD_LOJA]); end; if access_token <> '' then begin AResponseContent := TStringStream.Create(''); JsonToSend := TStringStream.Create(JSON_BOLETO, TEncoding.UTF8); with SSL.SSLOptions do begin CertFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CERTIFICADO.crt'; KeyFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CHAVE_PRIVADA.key'; Mode :=sslmUnassigned; Method :=sslvSSLv23; SSLVersions :=[sslvSSLv23]; end; URL :='está url está no portal do developers itau'; with HttpClient do begin IOHandler :=IOHandler; Request.Clear; Request.CharSet := 'utf-8'; Request.Accept := '*/*'; Request.AcceptEncoding := 'gzip, deflate, br'; Request.ContentType := 'application/json'; Request.CustomHeaders.Values['Authorization'] :='Bearer '+access_token; Request.CustomHeaders.Values['x-itau-apikey'] :=DM.SQL_busca_contaClientID.AsString; Request.CustomHeaders.Values['x-itau-flowID'] :=DM.SQL_busca_contaClientID.AsString + 'd7'; Request.CustomHeaders.Values['x-itau-correlationID'] := DM.SQL_busca_contaClientSecret.AsString; Request.UserAgent :='Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Maxthon; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)'; HandleRedirects := True; HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth]; end; try RESULTADO_BOLETO :=''; RESULTADO_BOLETO :=HttpClient.Post(URL, JsontoSend); except on E: Exception do begin ERRO_ITTAU :='SIM'; RESULTADO_BOLETO :=HttpClient.ResponseText; ArquivoJSON :=''; ArquivoJSON := RESULTADO_BOLETO; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end end; if HttpClient.ResponseCode = 200 then begin ArquivoJSON :=''; ArquivoJSON := RESULTADO_BOLETO; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); TextoOriginal :=''; valorTexto :=''; TextoOriginal := RESULTADO_BOLETO; valorTexto := Copy(TextoOriginal , Pos('numero_linha_digitavel', TextoOriginal) + 26, Length(TextoOriginal)); LINHA_DIGITAVEL :=''; LINHA_DIGITAVEL := Copy(valorTexto,1, 47); TextoOriginal :=''; valorTexto :=''; TextoOriginal := RESULTADO_BOLETO; valorTexto := Copy(TextoOriginal , Pos('codigo_barras', TextoOriginal) + 17, Length(TextoOriginal)); COD_BARRA_BOLETO := ''; COD_BARRA_BOLETO := Copy(valorTexto,1, 44); XMLTemporario.Append; XMLTemporarioNossoNumero.AsString :=LINHA_DIGITAVEL; if Length(OnlyNumber(LINHA_DIGITAVEL)) = 47 then begin XMLTemporarioStatus.AsString :='OK'; XMLTemporarioObs.AsString :='Boleto Registrado com Sucesso'; end else begin ERRO_ITTAU :='SIM'; XMLTemporarioStatus.AsString :='ERRO'; XMLTemporarioObs.AsString :='Erro ao Registrar Boleto via API'; end; XMLTemporarioNumeroDocumento.AsString :=NR_DOCUMENTO; XMLTemporarioParcela.AsInteger :=NR_PARCELA; XMLTemporario.Post; XMLTemporario.Close; XMLTemporario.Open; end else begin ERRO_ITTAU :='SIM'; ArquivoJSON :=''; ArquivoJSON := HttpClient.ResponseText; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end; end; finally FreeAndNil(HttpClient); FreeAndNil(SSL); end; end;
  23. Boa tarde, esse é meu códgio para obter o token bearer e emissão de boleto na API v2 do itaú, feito com indy. Implementação concluida com sucesso.API de Cobrança v2 Itaú. uses IdHTTP, IdIOHandlerStack, IdSSL, blcksock, System.Json, IdGlobalProtocols, IdSSLOpenSSL, synautil, synsock, ssl_openssl; procedure TF_boleto.EnviarBoletoItau; var mURL, sResponse, mCode : string; HTTP, HttpClient: TIdHTTP; FParams, access_token, refresh_token : String; Json, scope, token_type, expires_in, RESULTADO_BOLETO : String; JsontoSend, AResponseContent : TStringStream; var IOHandler : TIdSSLIOHandlerSocketOpenSSL; var Resp, Req, Resp_Cobranca, Req_Cobranca: TStringStream; var Result, s, recieveID, DATA_EMISSAO, DATA_VENCIMENTO, ArquivoJSON, ACESSO_TOKEN, RESULTADO_TOKEN, valorTexto : String; var TICKET_XML, XML_COBRANCA : TStringList; var newFile, Arq_Liberacao : TextFile; var TICKET, RET_CODE, TIPO_PESSOA, TIPO_AMBIENTE, NSU, sCAMINHGO_EXE, FURLToken, URL, NUMERO_CADASTRO_PESSOA, JSON_TOKEN, JSON_BOLETO : String; var DIAS_MULTA, DATA_HORA_TOKEN : Integer; XMLResponse, TIPO_VALIDACAO, ID_BENEFICIARIO, VALOR_BOLETO, TIPO_CLIENTE, VALOR_JUROS, VALOR_MULTAS, TextoOriginal : String; var JsonStreamRetorno, JsonStreamEnvio: TStringStream; SSL : TIdSSLIOHandlerSocketOpenSSL; begin //-----Todo conhecimento que o homem possui é dada por DEUS------------------- if Length(DM.SQL_contas_receber_boletoCPF_CNPJ_Cliente.AsString) = 14 then begin TIPO_CLIENTE := 'J'; NUMERO_CADASTRO_PESSOA := 'numero_cadastro_nacional_pessoa_juridica'; end else begin TIPO_CLIENTE := 'F'; NUMERO_CADASTRO_PESSOA := 'numero_cadastro_pessoa_fisica'; end; DATA_EMISSAO :=PegarNumeros(DateToStr(DM.SQL_contas_receber_boletoDetalhe_Data_Emissao.AsDateTime)); DATA_VENCIMENTO :=PegarNumeros(DateToStr(DM.SQL_contas_receber_boletoDetalhe_Data_Vencimento.AsDateTime)); TIPO_VALIDACAO :=''; if DM.TIPO_AMBIENTE_BOLETO = 'Homologação' then begin TIPO_VALIDACAO :='validacao'; end else begin TIPO_VALIDACAO :='efetivacao'; end; DATA_EMISSAO :=Copy(DATA_EMISSAO, 5, 4)+ '-'+ Copy(DATA_EMISSAO, 3, 2)+ '-'+Copy(DATA_EMISSAO, 1, 2); DATA_VENCIMENTO :=Copy(DATA_VENCIMENTO , 5, 4)+ '-'+ Copy(DATA_VENCIMENTO , 3, 2)+ '-'+Copy(DATA_VENCIMENTO , 1, 2); ID_BENEFICIARIO :=''; ID_BENEFICIARIO :=DM.SQL_busca_contaEmpresa_Agencia.AsString + FormatFloat('0000000', DM.SQL_busca_contaEmpresa_conta.AsInteger) + DM.SQL_busca_contaEmpresa_Conta_Digito.AsString; VALOR_BOLETO :=''; VALOR_BOLETO :=PegarNumeros(FormatFloat('#000000000000000.00', DM.SQL_contas_receber_boletoDetalhe_Valor_Falta.AsFloat)); VALOR_MULTAS :=PegarNumeros(FormatFloat('#000000000000000.00', roundabnt(DM.SQL_busca_contaMULTA_DIA.AsFloat,-2))); VALOR_JUROS :=PegarNumeros(FormatFloat('#000000000000000.00', roundabnt(VALOR_MOURA_JUROS,-2))); JSON_BOLETO :='{' + #13 + ' "data": {' + #13 + ' "etapa_processo_boleto": "'+TIPO_VALIDACAO+'",' + #13 + ' "codigo_canal_operacao": "API",' + #13 + ' "beneficiario": {' + #13 + ' "id_beneficiario": "'+ID_BENEFICIARIO+'"' + #13 + ' },' + #13 + ' "dado_boleto": {' + #13 + ' "descricao_instrumento_cobranca": "boleto",' + #13 + ' "tipo_boleto": "a vista",' + #13 + ' "codigo_carteira": "'+DM.SQL_busca_contaCarteira.AsString +'",' + #13 + ' "valor_total_titulo": "'+VALOR_BOLETO+'",' + #13 + ' "codigo_especie": "01",' + #13 + ' "valor_abatimento": "000",' + #13 + ' "data_emissao": "'+DATA_EMISSAO+'",' + #13 + ' "indicador_pagamento_parcial": false,' + #13 + ' "quantidade_maximo_parcial": 0,' + #13 + ' "pagador": {' + #13 + ' "pessoa": {' + #13 + ' "nome_pessoa": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoNomeRazaoSocial.AsString, 1, 50)))+'",' + #13 + ' "tipo_pessoa": {' + #13 + ' "codigo_tipo_pessoa": "'+TIPO_CLIENTE+'",' + #13 + ' "'+NUMERO_CADASTRO_PESSOA+'": "'+DM.SQL_contas_receber_boletoCPF_CNPJ_Cliente.AsString+'"' + #13 + ' }' + #13 + ' },' + #13 + ' "endereco": {' + #13 + ' "nome_logradouro": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoEndereco.AsString, 1, 40)))+ ', '+Copy(DM.SQL_contas_receber_boletoNumero.AsString, 1, 5)+'",' + #13 + ' "nome_bairro": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoBairro.AsString, 1, 40)))+'",' + #13 + ' "nome_cidade": "'+TrocaEComercialPorE(TiraAcentos(Copy(DM.SQL_contas_receber_boletoCidade.AsString, 1, 40)))+'",' + #13 + ' "sigla_UF": "'+DM.SQL_contas_receber_boletoUF.AsString+'",' + #13 + ' "numero_CEP": "'+DM.SQL_contas_receber_boletoCEP.AsString+'"' + #13 + ' }' + #13 + ' },' + #13 + ' "dados_individuais_boleto": [{' + #13 + ' "numero_nosso_numero": "'+sNOSSO_NUMERO_ITAU+'",' + #13 + ' "data_vencimento": "'+DATA_VENCIMENTO+'",' + #13 + ' "valor_titulo": "'+VALOR_BOLETO+'",' + #13 + ' "texto_uso_beneficiario": "'+DM.SQL_contas_receber_boletoDetalhe_N_Parcela.AsString+'",' + #13 + ' "texto_seu_numero": "'+DM.SQL_contas_receber_boletoDetalhe_N_Documento.AsString+'"' + #13 + ' }],' + #13 + ' "multa": {' + #13 + ' "codigo_tipo_multa": "02",' + #13 + ' "quantidade_dias_multa": 1,' + #13 + ' "percentual_multa": "'+VALOR_MULTAS+'"' + #13 + ' },' + #13 + ' "juros": {' + #13 + ' "codigo_tipo_juros": 93,' + #13 + ' "quantidade_dias_juros": 1,' + #13 + ' "valor_juros": "'+VALOR_JUROS+'"' + #13 + ' },' + #13 + ' "recebimento_divergente": {' + #13 + ' "codigo_tipo_autorizacao": "03"' + #13 + ' },' + #13 + // ' "instrucao_cobranca": [' + #13 + // ' {' + #13 + // ' "codigo_instrucao_cobranca": "4",' + #13 + // ' "quantidade_dias_apos_vencimento":60,' + #13 + // ' "dia_util":false' + #13 + // ' } ' + #13 + // ' ], ' + #13 + ' "protesto": {' + #13 + ' "protesto": 4,' + #13 + ' "quantidade_dias_protesto": 1' + #13 + ' },' + #13 + ' "negativacao": { ' + #13 + ' "negativacao": 5, ' + #13 + ' "quantidade_dias_negativacao": 1 ' + #13 + ' }, ' + #13 + ' ' + #13 + ' "desconto_expresso": false' + #13 + ' }' + #13 + ' }' + #13 + '}'; ArquivoJSON := ''; ArquivoJSON := JSON_BOLETO; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim('Registro _Itau_'+sNOSSO_NUMERO_ITAU) + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); RESULTADO_TOKEN :=''; access_token :=''; JSON_TOKEN := 'grant_type=client_credentials&client_id='+ DM.SQL_busca_contaClientID.AsString+'&client_secret='+DM.SQL_busca_contaClientSecret.AsString; try HttpClient := TIdHTTP.Create( nil ); SSL := TIdSSLIOHandlerSocketOpenSSL.Create(nil); HttpClient.IOHandler := SSL; JsonStreamEnvio := TStringStream.Create(utf8Encode(JSON_TOKEN)); DATA_HORA_TOKEN :=DM.conecta.ExecSQLScalar('SELECT IFNULL(TIMESTAMPDIFF (MINUTE,Data_access_token,NOW()),8) AS QTD_Horas FROM configuracao_boleto where Codigo_Config_Boleto =:BANCO and CodLoja_Boleto =:COD_LOJA', [DM.COD_BANCO, DM.COD_LOJA]); if DATA_HORA_TOKEN >= 4 then begin with SSL.SSLOptions do begin CertFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CERTIFICADO.crt'; KeyFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CHAVE_PRIVADA.key'; Mode := sslmUnassigned; Method := sslvSSLv23; SSLVersions := [sslvSSLv23]; end; URL :='essa url está no portal do developers itau'; with HttpClient do begin Request.CharSet := 'utf-8'; Request.Accept := '*/*'; Request.AcceptEncoding := 'gzip, deflate, br'; Request.CustomHeaders.Values['Content-Type'] := 'application/x-www-form-urlencoded'; Request.CustomHeaders.Values['x-itau-flowID'] := DM.SQL_busca_contaClientID.AsString + 'd7'; Request.CustomHeaders.Values['x-itau-correlationID'] := DM.SQL_busca_contaClientSecret.AsString; Request.UserAgent := 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Maxthon; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)'; HandleRedirects := True; HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth]; end; try RESULTADO_TOKEN := HttpClient.Post(URL,JsonStreamEnvio); Except on E: Exception do begin ERRO_ITTAU :='SIM'; RESULTADO_TOKEN :=HttpClient.ResponseText; ArquivoJSON :=''; ArquivoJSON := RESULTADO_TOKEN; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end; end; if HttpClient.ResponseCode = 200 then begin access_token :=''; expires_in :=''; access_token :=getCamposJsonString(RESULTADO_TOKEN, 'access_token'); expires_in :=getCamposJsonString(RESULTADO_TOKEN, 'expires_in'); scope :=getCamposJsonString(RESULTADO_TOKEN, 'scope'); DM.conecta.ExecSQL('update configuracao_boleto set access_token =:TOKEN, Scope =:SCOPE, expires_in =:EXPIRA, Data_access_token =NOW() where Codigo_Config_Boleto =:BANCO and CodLoja_Boleto =:COD_LOJA', [access_token, scope, StrToInt(expires_in), DM.COD_BANCO, DM.COD_LOJA]); end else begin ERRO_ITTAU :='SIM'; ArquivoJSON :=''; ArquivoJSON := RESULTADO_TOKEN; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end; end else begin access_token :=''; access_token :=DM.conecta.ExecSQLScalar('select IFNULL(access_token, "") AS token from configuracao_boleto where Codigo_Config_Boleto =:BANCO and CodLoja_Boleto =:COD_LOJA', [DM.COD_BANCO, DM.COD_LOJA]); end; if access_token <> '' then begin AResponseContent := TStringStream.Create(''); JsonToSend := TStringStream.Create(JSON_BOLETO, TEncoding.UTF8); with SSL.SSLOptions do begin CertFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CERTIFICADO.crt'; KeyFile := ExtractFilePath(ParamStr(0)) +'Boletos\Certificado\Itau\ARQUIVO_CHAVE_PRIVADA.key'; Mode :=sslmUnassigned; Method :=sslvSSLv23; SSLVersions :=[sslvSSLv23]; end; URL :='está url está no portal do developers itau'; with HttpClient do begin IOHandler :=IOHandler; Request.Clear; Request.CharSet := 'utf-8'; Request.Accept := '*/*'; Request.AcceptEncoding := 'gzip, deflate, br'; Request.ContentType := 'application/json'; Request.CustomHeaders.Values['Authorization'] :='Bearer '+access_token; Request.CustomHeaders.Values['x-itau-apikey'] :=DM.SQL_busca_contaClientID.AsString; Request.CustomHeaders.Values['x-itau-flowID'] :=DM.SQL_busca_contaClientID.AsString + 'd7'; Request.CustomHeaders.Values['x-itau-correlationID'] := DM.SQL_busca_contaClientSecret.AsString; Request.UserAgent :='Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0; Acoo Browser; GTB5; Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1) ; Maxthon; InfoPath.1; .NET CLR 3.5.30729; .NET CLR 3.0.30618)'; HandleRedirects := True; HTTPOptions := [hoKeepOrigProtocol, hoInProcessAuth]; end; try RESULTADO_BOLETO :=''; RESULTADO_BOLETO :=HttpClient.Post(URL, JsontoSend); except on E: Exception do begin ERRO_ITTAU :='SIM'; RESULTADO_BOLETO :=HttpClient.ResponseText; ArquivoJSON :=''; ArquivoJSON := RESULTADO_BOLETO; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end end; if HttpClient.ResponseCode = 200 then begin ArquivoJSON :=''; ArquivoJSON := RESULTADO_BOLETO; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); TextoOriginal :=''; valorTexto :=''; TextoOriginal := RESULTADO_BOLETO; valorTexto := Copy(TextoOriginal , Pos('numero_linha_digitavel', TextoOriginal) + 26, Length(TextoOriginal)); LINHA_DIGITAVEL :=''; LINHA_DIGITAVEL := Copy(valorTexto,1, 47); TextoOriginal :=''; valorTexto :=''; TextoOriginal := RESULTADO_BOLETO; valorTexto := Copy(TextoOriginal , Pos('codigo_barras', TextoOriginal) + 17, Length(TextoOriginal)); COD_BARRA_BOLETO := ''; COD_BARRA_BOLETO := Copy(valorTexto,1, 44); XMLTemporario.Append; XMLTemporarioNossoNumero.AsString :=LINHA_DIGITAVEL; if Length(OnlyNumber(LINHA_DIGITAVEL)) = 47 then begin XMLTemporarioStatus.AsString :='OK'; XMLTemporarioObs.AsString :='Boleto Registrado com Sucesso'; end else begin ERRO_ITTAU :='SIM'; XMLTemporarioStatus.AsString :='ERRO'; XMLTemporarioObs.AsString :='Erro ao Registrar Boleto via API'; end; XMLTemporarioNumeroDocumento.AsString :=NR_DOCUMENTO; XMLTemporarioParcela.AsInteger :=NR_PARCELA; XMLTemporario.Post; XMLTemporario.Close; XMLTemporario.Open; end else begin ERRO_ITTAU :='SIM'; ArquivoJSON :=''; ArquivoJSON := HttpClient.ResponseText; sCAMINHGO_EXE := (ExtractFilePath(ParamStr(0)) +'Boletos\LogsWebservice\'); System.AssignFile(newFile, sCAMINHGO_EXE + Trim(sNOSSO_NUMERO_ITAU +'_erro_retorno_itau') + '.json'); System.Rewrite(newFile); WriteLn(newFile, ArquivoJSON); System.CloseFile(newFile); end; end; finally FreeAndNil(HttpClient); FreeAndNil(SSL); end; end;
  24. Boa tarde, hoje recebi as credenciais do itaú, eu estou conseguindo gerar o tokem bearer mais na hora de emitir o boleto recebo o retorno HTTP/1.1 403 Forbidden, olhando o retorno de erro 403 é (Acesso Proibido), enviei um e-mail para o itau para eles verificar se tem algum bloqueio no acesso a API de Boleto v2.
  25. Boa tarde, hoje recebi as credenciais do itaú, eu estou conseguindo gerar o tokem bearer mais na hora de emitir o boleto recebo o retorno HTTP/1.1 403 Forbidden, olhando o retorno de erro 403 é (Acesso Proibido), enviei um e-mail para o itau para eles verificar se tem algum bloqueio no acesso a API de Boleto v2.
×
×
  • Criar Novo...

Informação Importante

Colocamos cookies em seu dispositivo para ajudar a tornar este site melhor. Você pode ajustar suas configurações de cookies, caso contrário, assumiremos que você está bem para continuar.

The popup will be closed in 10 segundos...