Chilkat Examples

ChilkatHOME.NET Core C#Android™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi ActiveXDelphi DLLGoJavaLianjaMono C#Node.jsObjective-CPHP ActiveXPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwift 2Swift 3,4,5...TclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

Visual FoxPro Examples

Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
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
Misc
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
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(Visual FoxPro) 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.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

LOCAL lnSuccess
LOCAL loJson
LOCAL loCert
LOCAL loCrypt
LOCAL lcSigBase64
LOCAL lcUrl
LOCAL loReq
LOCAL loHttp
LOCAL loResp

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

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

* Load out PFX file 
* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Cert')
loCert = CreateObject('Chilkat.Cert')
lnSuccess = loCert.LoadPfxFile("qa_data/pfx/cert_test123.pfx","test123")
IF (lnSuccess <> 1) THEN
    ? loCert.LastErrorText
    RELEASE loJson
    RELEASE loCert
    CANCEL
ENDIF

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Crypt2')
loCrypt = CreateObject('Chilkat.Crypt2')
lnSuccess = loCrypt.SetSigningCert(loCert)
IF (lnSuccess <> 1) THEN
    ? loCrypt.LastErrorText
    RELEASE loJson
    RELEASE loCert
    RELEASE loCrypt
    CANCEL
ENDIF

* Use SHA-256 within the signing..
loCrypt.HashAlgorithm = "sha256"

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

loJson.EmitCompact = 1
lcSigBase64 = loCrypt.OpaqueSignStringENC(loJson.Emit())
IF (loCrypt.LastMethodSuccess <> 1) THEN
    ? loCrypt.LastErrorText
    RELEASE loJson
    RELEASE loCert
    RELEASE loCrypt
    CANCEL
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).
lcUrl = "https://cobranca.bradesconetempresa.b.br/ibpjregistrotitulows/registrotitulohomologacao"

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.HttpRequest')
loReq = CreateObject('Chilkat.HttpRequest')
loReq.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.
loReq.ContentType = "text/xml"
loReq.LoadBodyFromString(lcSigBase64,"utf-8")

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

* For versions of Chilkat < 10.0.0, use CreateObject('Chilkat_9_5_0.Http')
loHttp = CreateObject('Chilkat.Http')
loResp = loHttp.SynchronousRequest("cobranca.bradesconetempresa.b.br",443,1,loReq)
IF (loHttp.LastMethodSuccess <> 1) THEN
    ? loHttp.LastErrorText
    RELEASE loJson
    RELEASE loCert
    RELEASE loCrypt
    RELEASE loReq
    RELEASE loHttp
    CANCEL
ENDIF

? "Response status code: " + STR(loResp.StatusCode)
? "Response body:"
? loResp.BodyStr

RELEASE loResp

RELEASE loJson
RELEASE loCert
RELEASE loCrypt
RELEASE loReq
RELEASE loHttp


 

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