Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

Excel Examples

Web API Categories

ASN.1
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Azure Cloud Storage
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP

HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
MS Storage Providers
Microsoft Graph
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Excel) Send POST to Bradesco Platform with Billing Ticket for Registration

Sends 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.

Download Excel Class Modules

Chilkat Excel Class Modules

' 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",
' }
' 

Dim json As Chilkat.JsonObject
Set json = Chilkat.NewJsonObject
success = json.UpdateString("nuCPFCNPJ","12668")
success = json.UpdateString("filialCPFCNPJ","1")
success = json.UpdateString("ctrlCPFCNPJ","59")
success = json.UpdateString("cdTipoAcesso","2")
success = json.UpdateString("idProduto","9")
success = json.UpdateString("nuNegociacao","262200000000005577")
success = json.UpdateString("nuCliente","SEU_NUM_CLIENTE")
success = json.UpdateString("dtEmissaoTitulo","21.09.2016")
success = json.UpdateString("dtVencimentoTitulo","21.09.2016")
success = json.UpdateString("vlNominalTitulo","888888")
success = json.UpdateString("cdEspecieTitulo","2")
success = json.UpdateString("nomePagador","NOME DO PAGADOR")
success = json.UpdateString("logradouroPagador","ENDERECO DO PAGADOR")
success = json.UpdateString("nuLogradouroPagador","1145")
success = json.UpdateString("complementoLogradouroPagador","APTO 34")
success = json.UpdateString("cepPagador","5588")
success = json.UpdateString("complementoCepPagador","1")
success = json.UpdateString("bairroPagador","BAIRRO PAGADOR")
success = json.UpdateString("municipioPagador","MUNICIPIO PAGADOR")
success = json.UpdateString("ufPagador","SP")
success = json.UpdateString("cdIndCpfcnpjPagador","2")
success = json.UpdateString("nuCpfcnpjPagador","12668000159")
success = json.UpdateString("endEletronicoPagador","PAGADOR@BRADESCO.COM.BR")
success = json.UpdateString("nomeSacadorAvalista","NOME SACADOR AVALISTA")
success = json.UpdateString("logradouroSacadorAvalista","ENDERECO SACADOR AVALISTA")
success = json.UpdateString("nuLogradouroSacadorAvalista","5555")
success = json.UpdateString("complementoLogradouroSacadorAvalista","BLOCO 23")
success = json.UpdateString("cepSacadorAvalista","6182")
success = json.UpdateString("complementoCepSacadorAvalista","160")
success = json.UpdateString("bairroSacadorAvalista","BAIRRO SACADOR AVALISTA")
success = json.UpdateString("municipioSacadorAvalista","MUNICIPIO SACADOR AVALISTA")
success = json.UpdateString("ufSacadorAvalista","SP")
success = json.UpdateString("cdIndCpfcnpjSacadorAvalista","2")
success = json.UpdateString("nuCpfcnpjSacadorAvalista","12668000159")
success = json.UpdateString("endEletronicoSacadorAvalista","SACADOR@BRADESCO.COM.BR")

' Load out PFX file 
Dim cert As Chilkat.Cert
Set cert = Chilkat.NewCert
success = cert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123")
If (success <> True) Then
    Debug.Print cert.LastErrorText
    Exit Sub
End If

Dim crypt As Chilkat.Crypt2
Set crypt = Chilkat.NewCrypt2
success = crypt.SetSigningCert(cert)
If (success <> True) Then
    Debug.Print crypt.LastErrorText
    Exit Sub
End If

' Use SHA-256 within the signing..
crypt.HashAlgorithm = "sha256"

' IMPORTANT: This example requires Chilkat v9.5.0.77 or later.
' Use no authenticated attributes
crypt.SigningAttributes = "{}"

json.EmitCompact = True

sigBase64 = crypt.OpaqueSignStringENC(json.Emit())
If (crypt.LastMethodSuccess <> True) Then
    Debug.Print crypt.LastErrorText
    Exit Sub
End If

' 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).

url = "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulohomologacao"

Dim req As Chilkat.HttpRequest
Set req = Chilkat.NewHttpRequest
req.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.
req.ContentType = "text/xml"
success = req.LoadBodyFromString(sigBase64,"utf-8")

' We don't actually pass the URL, we set the path here, and the domain is passed below..
req.Path = "/ibpjregistrotitulows/registrotitulohomologacao"

Dim http As Chilkat.Http
Set http = Chilkat.NewHttp

Set resp = http.SynchronousRequest("cobranca.bradesconetempresa.b.br",443,True,req)
If (http.LastMethodSuccess <> True) Then
    Debug.Print http.LastErrorText
    Exit Sub
End If

Debug.Print "Response status code: "; resp.StatusCode
Debug.Print "Response body:"
Debug.Print resp.BodyStr


 

© 2000-2022 Chilkat Software, Inc. All Rights Reserved.