Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(Tcl) Send POST to Bradesco Platform with Billing Ticket for RegistrationSends a POST request to the Bradesco platform containing the JSON data of the Billing Ticket for registration. Note: This example requires updates that are in Chilkat v9.5.0.77 and later.
load ./chilkat.dll # This example requires the Chilkat API to have been previously unlocked. # See Global Unlock Sample for sample code. # First build the JSON containing the data to be sent. # { # "nuCPFCNPJ":"12668", # "filialCPFCNPJ":"1", # "ctrlCPFCNPJ":"59", # "cdTipoAcesso":"2", # "idProduto":"9", # "nuNegociacao":"262200000000005577", # "nuCliente":"SEU_NUM_CLIENTE", # "dtEmissaoTitulo":"21.09.2016", # "dtVencimentoTitulo":"21.09.2016", # "vlNominalTitulo":"888888", # "cdEspecieTitulo":"2", # "nomePagador":"NOME DO PAGADOR", # "logradouroPagador":"ENDERECO DO PAGADOR", # "nuLogradouroPagador":"1145", # "complementoLogradouroPagador":"APTO 34", # "cepPagador":"5588", # "complementoCepPagador":"1", # "bairroPagador":"BAIRRO PAGADOR", # "municipioPagador":"MUNICIPIO PAGADOR", # "ufPagador":"SP", # "cdIndCpfcnpjPagador":"2", # "nuCpfcnpjPagador":"12668000159", # "endEletronicoPagador":"PAGADOR@BRADESCO.COM.BR", # "nomeSacadorAvalista":"NOME SACADOR AVALISTA", # "logradouroSacadorAvalista":"ENDERECO SACADOR AVALISTA", # "nuLogradouroSacadorAvalista":"5555", # "complementoLogradouroSacadorAvalista":"BLOCO 23", # "cepSacadorAvalista":"6182", # "complementoCepSacadorAvalista":"160", # "bairroSacadorAvalista":"BAIRRO SACADOR AVALISTA", # "municipioSacadorAvalista":"MUNICIPIO SACADOR AVALISTA", # "ufSacadorAvalista":"SP", # "cdIndCpfcnpjSacadorAvalista":"2", # "nuCpfcnpjSacadorAvalista":"12668000159", # "endEletronicoSacadorAvalista":"SACADOR@BRADESCO.COM.BR", # } # set json [new_CkJsonObject] CkJsonObject_UpdateString $json "nuCPFCNPJ" "12668" CkJsonObject_UpdateString $json "filialCPFCNPJ" "1" CkJsonObject_UpdateString $json "ctrlCPFCNPJ" "59" CkJsonObject_UpdateString $json "cdTipoAcesso" "2" CkJsonObject_UpdateString $json "idProduto" "9" CkJsonObject_UpdateString $json "nuNegociacao" "262200000000005577" CkJsonObject_UpdateString $json "nuCliente" "SEU_NUM_CLIENTE" CkJsonObject_UpdateString $json "dtEmissaoTitulo" "21.09.2016" CkJsonObject_UpdateString $json "dtVencimentoTitulo" "21.09.2016" CkJsonObject_UpdateString $json "vlNominalTitulo" "888888" CkJsonObject_UpdateString $json "cdEspecieTitulo" "2" CkJsonObject_UpdateString $json "nomePagador" "NOME DO PAGADOR" CkJsonObject_UpdateString $json "logradouroPagador" "ENDERECO DO PAGADOR" CkJsonObject_UpdateString $json "nuLogradouroPagador" "1145" CkJsonObject_UpdateString $json "complementoLogradouroPagador" "APTO 34" CkJsonObject_UpdateString $json "cepPagador" "5588" CkJsonObject_UpdateString $json "complementoCepPagador" "1" CkJsonObject_UpdateString $json "bairroPagador" "BAIRRO PAGADOR" CkJsonObject_UpdateString $json "municipioPagador" "MUNICIPIO PAGADOR" CkJsonObject_UpdateString $json "ufPagador" "SP" CkJsonObject_UpdateString $json "cdIndCpfcnpjPagador" "2" CkJsonObject_UpdateString $json "nuCpfcnpjPagador" "12668000159" CkJsonObject_UpdateString $json "endEletronicoPagador" "PAGADOR@BRADESCO.COM.BR" CkJsonObject_UpdateString $json "nomeSacadorAvalista" "NOME SACADOR AVALISTA" CkJsonObject_UpdateString $json "logradouroSacadorAvalista" "ENDERECO SACADOR AVALISTA" CkJsonObject_UpdateString $json "nuLogradouroSacadorAvalista" "5555" CkJsonObject_UpdateString $json "complementoLogradouroSacadorAvalista" "BLOCO 23" CkJsonObject_UpdateString $json "cepSacadorAvalista" "6182" CkJsonObject_UpdateString $json "complementoCepSacadorAvalista" "160" CkJsonObject_UpdateString $json "bairroSacadorAvalista" "BAIRRO SACADOR AVALISTA" CkJsonObject_UpdateString $json "municipioSacadorAvalista" "MUNICIPIO SACADOR AVALISTA" CkJsonObject_UpdateString $json "ufSacadorAvalista" "SP" CkJsonObject_UpdateString $json "cdIndCpfcnpjSacadorAvalista" "2" CkJsonObject_UpdateString $json "nuCpfcnpjSacadorAvalista" "12668000159" CkJsonObject_UpdateString $json "endEletronicoSacadorAvalista" "SACADOR@BRADESCO.COM.BR" # Load out PFX file set cert [new_CkCert] set success [CkCert_LoadPfxFile $cert "qa_data/pfx/cert_test123.pfx" "test123"] if {$success != 1} then { puts [CkCert_lastErrorText $cert] delete_CkJsonObject $json delete_CkCert $cert exit } set crypt [new_CkCrypt2] set success [CkCrypt2_SetSigningCert $crypt $cert] if {$success != 1} then { puts [CkCrypt2_lastErrorText $crypt] delete_CkJsonObject $json delete_CkCert $cert delete_CkCrypt2 $crypt exit } # Use SHA-256 within the signing.. CkCrypt2_put_HashAlgorithm $crypt "sha256" # IMPORTANT: This example requires Chilkat v9.5.0.77 or later. # Use no authenticated attributes CkCrypt2_put_SigningAttributes $crypt "{}" CkJsonObject_put_EmitCompact $json 1 set sigBase64 [CkCrypt2_opaqueSignStringENC $crypt [CkJsonObject_emit $json]] if {[CkCrypt2_get_LastMethodSuccess $crypt] != 1} then { puts [CkCrypt2_lastErrorText $crypt] delete_CkJsonObject $json delete_CkCert $cert delete_CkCrypt2 $crypt exit } # Next, we need to send a POST to the following URL where the body of the POST # contains the binary PKCS7 signature (which embeds the JSON). set url "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulohomologacao" set req [new_CkHttpRequest] CkHttpRequest_put_HttpVerb $req "POST" # This is strange because apparently the server wants a "text/xml" Content-Type, # but the content in the body is not actually XML, it's binary PKCS7. CkHttpRequest_put_ContentType $req "text/xml" CkHttpRequest_LoadBodyFromString $req $sigBase64 "utf-8" # We don't actually pass the URL, we set the path here, and the domain is passed below.. CkHttpRequest_put_Path $req "/ibpjregistrotitulows/registrotitulohomologacao" set http [new_CkHttp] # resp is a CkHttpResponse set resp [CkHttp_SynchronousRequest $http "cobranca.bradesconetempresa.b.br" 443 1 $req] if {[CkHttp_get_LastMethodSuccess $http] != 1} then { puts [CkHttp_lastErrorText $http] delete_CkJsonObject $json delete_CkCert $cert delete_CkCrypt2 $crypt delete_CkHttpRequest $req delete_CkHttp $http exit } puts "Response status code: [CkHttpResponse_get_StatusCode $resp]" puts "Response body:" puts [CkHttpResponse_bodyStr $resp] delete_CkHttpResponse $resp delete_CkJsonObject $json delete_CkCert $cert delete_CkCrypt2 $crypt delete_CkHttpRequest $req delete_CkHttp $http |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.