Ir para conteúdo
  • Cadastre-se

Jhonlenon Ribeiro

Membros
  • Total de ítens

    470
  • Registro em

  • Última visita

  • Days Won

    4

Tudo que Jhonlenon Ribeiro postou

  1. luisclaudio_jr era isso mesmo..um CT-e de Subcontratação....obrigado....pode encerrar o topico
  2. 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.
  3. 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
  4. 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.
  5. Gustavo Totta Bom dia...me chama no PV pra ver se consigo te ajudar
  6. 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.
  7. 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
  8. 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.
  9. 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.
  10. 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;
  11. 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;
  12. 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.
  13. 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.
  14. Será que o problema não está no scope? eu não entendi bem sobre aquele scope que eles fala que tem que informar no cadastro da aplicação consumidora no portal de certificados de parceiro. deve ser adicionado o scope/funcionalidade: boletoscash-boletos-consulta_titulo
  15. Rafael Mozer será que o itaú já tem o boleto híbrido na API de Boleto v2? eu estou olhando aqui no developers do itaú e não fala nada sobre o boleto híbrido com pix, fala apenas do boleto normal.
  16. Boa tarde, estou aqui na luta para homologar a API de Cobrança v2 do itaú, estou aguardando o retorno do suporte.
  17. Coletek MG Eu já tinha montando também meu código com indy...mais valeu por disponbilizar...também vou disponilizar o meu assim que testar. Eu ainda estou aguardando as credenciais (Cliente_ID e Token Temporário), me responde um coisa, quando vc recebeu o Client_ID e Token Temporário eles vieram descriptografado ou você teve de decifrar as credenciais? na outra solicitação que fiz ao itaú à uns 9 meses atrás eles me mandaram a Client_ID e Token temporário já decifrado, mais eu não sei se ainda é assim. Quando eu receber as credenciais vou testar essa parada da consulta do boleto também...caso tenho sucesso posto aqui pra você.
  18. Boa tarde, alguém já alterou o arquivo.fr3 do fast report do boleto hÍbrido PIX Banco do Brasil para formato de carnê, já tem um padrão da ACBr boleto híbrido PIX mais é em A4, eu tava precisando no formato de carnê.
  19. Boa tarde, abri minha conta PJ do Itaú e minha gerente conseguiu liberar a API de emissão de boleto na minha conta, estou aguardando o e-mail do suporte técnico onde eles solicita as informações necessarios para iniciar o processo de homologação...com dé em DEUS agora vou conseguir. A quase 1 ano atras tentei e não consegui...expliquei a situação para o meu cliente ai ele mandou eu CANCELAR o processo, mais agora eu consegui entender o processo todo no site do developers. Também tava usando a conta do cliente, não tinha muito acesso, mais agora minha propria conta PJ vai ser mais facíl. Na minha suite de boletos falta só itáu....rsrs Emissão de Boleto via API em produção no meu sistema 1 - Banco do Brasil 2 - Caixa Econimica 3 - Bradesco 4 - Santander 5 - Sicredi 6 - Sicoob 7 - Banco Inter 8 - Cooperativa Alios (Varias Cooperativas) 9 - Banco Banrisul 10 - Itaú (Em desenvolvimento)
  20. Coletek MG Você consegiu emitir boleto na API do Itaú na v2? vc pode compartilhar seu codigo aqui no forum?
  21. Victor H. Gonzales - Panda Obrigado pela ajuda....voltei a olhar o demo ACBrBoleto e conseguin pegar o retorno pelo json sem precisar do log....pode encerrar o topico.
  22. Victor H. Gonzales - Panda Como vc fez pra pegar esse retorno ai? era isso mesmo que preciso...tem como mostrar aqui?
  23. Victor H. Gonzales - Panda Eu fiz um teste seguinte o exemplo do demo mais não me retornou os dados...será que não precisa alterar alguma coisa naquela parte de retorno no demo? antes funcionava...
  24. Juliomar Marchetti Eu não encontrei esse arquivo showlog...para resolver o meu problema temporario eu fiz um tratamento no arquivo ArqBoletoWS.log.....nele tem toda a movimentação do processo de envio do boleto via API...json gerado...json retorno....log consulta...log de baixa...eu não sei se tem como pegar alguns dados sem ser pelo arquivo....tipo eu preciso sempre da LINHA DIGITAVÉL, CODIGO DE BARRAS DO BOLETO e quando é o boleto hibrido com Qrcode também salvo o emv do PIX..lembrando que estou usando o metido Enviar e não o EnviarBoleto. Hoje tenho no meu projeto a emissão do boleto no Banco do Brasil na v1 que é via XML ainda e também a v2 que é já na nova API do BB...ambas funcionando...no registro do boleto não mudou nada...apenas achei meio complicado pra obter o retorno do boleto.
×
×
  • 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.