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
(AutoIt) 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.
; 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", ; } ; Local $bSuccess $oJson = ObjCreate("Chilkat.JsonObject") $oJson.UpdateString("nuCPFCNPJ","12668") $oJson.UpdateString("filialCPFCNPJ","1") $oJson.UpdateString("ctrlCPFCNPJ","59") $oJson.UpdateString("cdTipoAcesso","2") $oJson.UpdateString("idProduto","9") $oJson.UpdateString("nuNegociacao","262200000000005577") $oJson.UpdateString("nuCliente","SEU_NUM_CLIENTE") $oJson.UpdateString("dtEmissaoTitulo","21.09.2016") $oJson.UpdateString("dtVencimentoTitulo","21.09.2016") $oJson.UpdateString("vlNominalTitulo","888888") $oJson.UpdateString("cdEspecieTitulo","2") $oJson.UpdateString("nomePagador","NOME DO PAGADOR") $oJson.UpdateString("logradouroPagador","ENDERECO DO PAGADOR") $oJson.UpdateString("nuLogradouroPagador","1145") $oJson.UpdateString("complementoLogradouroPagador","APTO 34") $oJson.UpdateString("cepPagador","5588") $oJson.UpdateString("complementoCepPagador","1") $oJson.UpdateString("bairroPagador","BAIRRO PAGADOR") $oJson.UpdateString("municipioPagador","MUNICIPIO PAGADOR") $oJson.UpdateString("ufPagador","SP") $oJson.UpdateString("cdIndCpfcnpjPagador","2") $oJson.UpdateString("nuCpfcnpjPagador","12668000159") $oJson.UpdateString("endEletronicoPagador","PAGADOR@BRADESCO.COM.BR") $oJson.UpdateString("nomeSacadorAvalista","NOME SACADOR AVALISTA") $oJson.UpdateString("logradouroSacadorAvalista","ENDERECO SACADOR AVALISTA") $oJson.UpdateString("nuLogradouroSacadorAvalista","5555") $oJson.UpdateString("complementoLogradouroSacadorAvalista","BLOCO 23") $oJson.UpdateString("cepSacadorAvalista","6182") $oJson.UpdateString("complementoCepSacadorAvalista","160") $oJson.UpdateString("bairroSacadorAvalista","BAIRRO SACADOR AVALISTA") $oJson.UpdateString("municipioSacadorAvalista","MUNICIPIO SACADOR AVALISTA") $oJson.UpdateString("ufSacadorAvalista","SP") $oJson.UpdateString("cdIndCpfcnpjSacadorAvalista","2") $oJson.UpdateString("nuCpfcnpjSacadorAvalista","12668000159") $oJson.UpdateString("endEletronicoSacadorAvalista","SACADOR@BRADESCO.COM.BR") ; Load out PFX file $oCert = ObjCreate("Chilkat.Cert") $bSuccess = $oCert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123") If ($bSuccess <> True) Then ConsoleWrite($oCert.LastErrorText & @CRLF) Exit EndIf $oCrypt = ObjCreate("Chilkat.Crypt2") $bSuccess = $oCrypt.SetSigningCert($oCert) If ($bSuccess <> True) Then ConsoleWrite($oCrypt.LastErrorText & @CRLF) Exit EndIf ; Use SHA-256 within the signing.. $oCrypt.HashAlgorithm = "sha256" ; IMPORTANT: This example requires Chilkat v9.5.0.77 or later. ; Use no authenticated attributes $oCrypt.SigningAttributes = "{}" $oJson.EmitCompact = True Local $sigBase64 = $oCrypt.OpaqueSignStringENC($oJson.Emit()) If ($oCrypt.LastMethodSuccess <> True) Then ConsoleWrite($oCrypt.LastErrorText & @CRLF) Exit EndIf ; 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). Local $sUrl = "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulohomologacao" $oReq = ObjCreate("Chilkat.HttpRequest") $oReq.HttpVerb = "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. $oReq.ContentType = "text/xml" $oReq.LoadBodyFromString($sigBase64,"utf-8") ; We don't actually pass the URL, we set the path here, and the domain is passed below.. $oReq.Path = "/ibpjregistrotitulows/registrotitulohomologacao" $oHttp = ObjCreate("Chilkat.Http") Local $oResp = $oHttp.SynchronousRequest("cobranca.bradesconetempresa.b.br",443,True,$oReq) If ($oHttp.LastMethodSuccess <> True) Then ConsoleWrite($oHttp.LastErrorText & @CRLF) Exit EndIf ConsoleWrite("Response status code: " & $oResp.StatusCode & @CRLF) ConsoleWrite("Response body:" & @CRLF) ConsoleWrite($oResp.BodyStr & @CRLF) |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.