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

Tcl Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Bitfinex v2 REST
Bluzone
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Etsy
Facebook
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
Jira
Lightspeed
MYOB
Magento
Mailgun
MedTunnel

MercadoLibre
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Okta OAuth/OIDC
OneLogin OIDC
OneNote
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
Trello
Twilio
Twitter
UniPin
VoiceBase
Vonage
Walmart
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yousign
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Tcl) Ibanity XS2A List Financial Institutions

See more Ibanity Examples

Demonstrates how to send a request to get a list of financial institutions.

For more information, see https://documentation.ibanity.com/xs2a/api/curl#authentication

Chilkat Tcl Extension Downloads

Chilkat Tcl Extension Downloads

load ./chilkat.dll

# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.

#  Send the following request:

# $ curl -X GET https://api.ibanity.com/xs2a/financial-institutions \
# --cert certificate.pem \
# --key private_key.pem \
# -H 'Signature: keyId="75b5d796-de5c-400a-81ce-e72371b01cbc",created=1599659223,algorithm="hs2019",headers="(request-target) digest (created) host",signature="BASE64(RSA-SHA256(SIGNING_STRING))"' \
# -H 'Digest: SHA-512=beDaRguyEb8fhh5wnl37bOTDtvhuYZyZNkTZ9LiC9Wc='

# Ibanity provides the certificate + private key in PFX format.  This example will use the .pfx instead of the pair of PEM files.
# (It is also possible to implement using Chilkat with the PEM files, but PFX is easier.)
set cert [new_CkCert]

set success [CkCert_LoadPfxFile $cert "qa_data/pfx/my_ibanity_certificate.pfx" "my_pfx_password"]
if {$success == 0} then {
    puts [CkCert_lastErrorText $cert]
    delete_CkCert $cert
    exit
}

# We need to calculate the Digest and Signature header fields.
# For a detailed explanation, see Calculate Ibanity HTTP Signature Example

# We'll just write the code here as briefly as possible.

set dtNow [new_CkDateTime]

CkDateTime_SetFromCurrentSystemTime $dtNow
set created [CkDateTime_getAsUnixTimeStr $dtNow 0]

set crypt2 [new_CkCrypt2]

CkCrypt2_put_HashAlgorithm $crypt2 "sha512"
CkCrypt2_put_EncodingMode $crypt2 "base64"

set sbDigestHdrValue [new_CkStringBuilder]

CkStringBuilder_Append $sbDigestHdrValue "SHA-512="
# GET requests have empty payloads.  The SHA-512 hash of the empty string is the same for all GET requests.
# Therefore all GET requests will use "z4PhNX7vuL3xVChQ1m2AB9Yg5AULVxXcg/SpIdNs6c5H0NE8XYXysP+DGNKHfuwvY7kxvUdBeoGlODJ6+SfaPg=="
# You can eliminate the explicit hash computation (for GET requests) and simply use the above literal string.
CkStringBuilder_Append $sbDigestHdrValue [CkCrypt2_hashStringENC $crypt2 ""]

puts "Generated Digest"
puts [CkStringBuilder_getAsString $sbDigestHdrValue]

set request_target "get /xs2a/financial-institutions"

set sbSigningString [new_CkStringBuilder]

CkStringBuilder_Append $sbSigningString "(request-target): "
CkStringBuilder_AppendLine $sbSigningString $request_target 0
CkStringBuilder_Append $sbSigningString "host: "
CkStringBuilder_AppendLine $sbSigningString "api.ibanity.com" 0
CkStringBuilder_Append $sbSigningString "digest: "
CkStringBuilder_AppendLine $sbSigningString [CkStringBuilder_getAsString $sbDigestHdrValue] 0
CkStringBuilder_Append $sbSigningString "(created): "
CkStringBuilder_Append $sbSigningString $created
# ibanity-idempotency-key is not used with GET requests.

puts "Signing String:"
puts [CkStringBuilder_getAsString $sbSigningString]

set signed_headers_list "(request-target) host digest (created)"

set privKey [new_CkPrivateKey]

set success [CkPrivateKey_LoadEncryptedPemFile $privKey "my_ibanity_signature_private_key.pem" "pem_password"]
if {$success == 0} then {
    puts [CkPrivateKey_lastErrorText $privKey]
    delete_CkCert $cert
    delete_CkDateTime $dtNow
    delete_CkCrypt2 $crypt2
    delete_CkStringBuilder $sbDigestHdrValue
    delete_CkStringBuilder $sbSigningString
    delete_CkPrivateKey $privKey
    exit
}

set rsa [new_CkRsa]

CkRsa_put_PssSaltLen $rsa 32
CkRsa_put_EncodingMode $rsa "base64"
# Use the RSASSA-PSS signature algorithm
CkRsa_put_OaepPadding $rsa 1

set success [CkRsa_ImportPrivateKeyObj $rsa $privKey]
if {$success == 0} then {
    puts [CkRsa_lastErrorText $rsa]
    delete_CkCert $cert
    delete_CkDateTime $dtNow
    delete_CkCrypt2 $crypt2
    delete_CkStringBuilder $sbDigestHdrValue
    delete_CkStringBuilder $sbSigningString
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    exit
}

# Sign the signing string.
set sigBase64 [CkRsa_signStringENC $rsa [CkStringBuilder_getAsString $sbSigningString] "sha-256"]
if {[CkRsa_get_LastMethodSuccess $rsa] == 0} then {
    puts [CkRsa_lastErrorText $rsa]
    delete_CkCert $cert
    delete_CkDateTime $dtNow
    delete_CkCrypt2 $crypt2
    delete_CkStringBuilder $sbDigestHdrValue
    delete_CkStringBuilder $sbSigningString
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    exit
}

puts "Signature:"
puts "$sigBase64"

# Build the signature header value.
set sbSigHeaderValue [new_CkStringBuilder]

CkStringBuilder_Append $sbSigHeaderValue "keyId=\""
# Use your identifier for the application's signature certificate, obtained from the Developer Portal
CkStringBuilder_Append $sbSigHeaderValue "a0ce296d-84c8-4bd5-8eb4-de0339950cfa"
CkStringBuilder_Append $sbSigHeaderValue "\",created="
CkStringBuilder_Append $sbSigHeaderValue $created
CkStringBuilder_Append $sbSigHeaderValue ",algorithm=\"hs2019\",headers=\""
CkStringBuilder_Append $sbSigHeaderValue $signed_headers_list
CkStringBuilder_Append $sbSigHeaderValue "\",signature=\""
CkStringBuilder_Append $sbSigHeaderValue $sigBase64
CkStringBuilder_Append $sbSigHeaderValue "\""

# Send the GET request..
set http [new_CkHttp]

set success [CkHttp_SetSslClientCert $http $cert]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkCert $cert
    delete_CkDateTime $dtNow
    delete_CkCrypt2 $crypt2
    delete_CkStringBuilder $sbDigestHdrValue
    delete_CkStringBuilder $sbSigningString
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkStringBuilder $sbSigHeaderValue
    delete_CkHttp $http
    exit
}

CkHttp_SetRequestHeader $http "Signature" [CkStringBuilder_getAsString $sbSigHeaderValue]
CkHttp_SetRequestHeader $http "Digest" [CkStringBuilder_getAsString $sbDigestHdrValue]

set sbResponseBody [new_CkStringBuilder]

set success [CkHttp_QuickGetSb $http "https://api.ibanity.com/xs2a/financial-institutions" $sbResponseBody]
if {$success == 0} then {
    puts [CkHttp_lastErrorText $http]
    delete_CkCert $cert
    delete_CkDateTime $dtNow
    delete_CkCrypt2 $crypt2
    delete_CkStringBuilder $sbDigestHdrValue
    delete_CkStringBuilder $sbSigningString
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkStringBuilder $sbSigHeaderValue
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    exit
}

set jResp [new_CkJsonObject]

CkJsonObject_LoadSb $jResp $sbResponseBody
CkJsonObject_put_EmitCompact $jResp 0

puts "Response Body:"
puts [CkJsonObject_emit $jResp]

set respStatusCode [CkHttp_get_LastStatus $http]
puts "Response Status Code = $respStatusCode"
if {$respStatusCode >= 400} then {
    puts "Response Header:"
    puts [CkHttp_lastHeader $http]
    puts "Failed."
    delete_CkCert $cert
    delete_CkDateTime $dtNow
    delete_CkCrypt2 $crypt2
    delete_CkStringBuilder $sbDigestHdrValue
    delete_CkStringBuilder $sbSigningString
    delete_CkPrivateKey $privKey
    delete_CkRsa $rsa
    delete_CkStringBuilder $sbSigHeaderValue
    delete_CkHttp $http
    delete_CkStringBuilder $sbResponseBody
    delete_CkJsonObject $jResp
    exit
}

# Sample output:
# (Sample code for parsing the JSON response is shown below)

# {
#   "data": [
#     {
#       "attributes": {
#         "authorizationModels": [
#           "detailed",
#           "financialInstitutionOffered"
#         ],
#         "bic": "NBBEBEBB203",
#         "bulkPaymentsEnabled": true,
#         "bulkPaymentsProductTypes": [
#           "sepaCreditTransfer"
#         ],
#         "country": null,
#         "financialInstitutionCustomerReferenceRequired": false,
#         "futureDatedPaymentsAllowed": true,
#         "logoUrl": "https://s3.eu-central-1.amazonaws.com/ibanity-production-financial-institution-assets/sandbox.png",
#         "maintenanceFrom": null,
#         "maintenanceTo": null,
#         "maintenanceType": null,
#         "maxRequestedAccountReferences": null,
#         "minRequestedAccountReferences": 0,
#         "name": "Bogus Financial",
#         "paymentsEnabled": true,
#         "paymentsProductTypes": [
#           "sepaCreditTransfer"
#         ],
#         "periodicPaymentsEnabled": true,
#         "periodicPaymentsProductTypes": [
#           "sepaCreditTransfer"
#         ],
#         "primaryColor": "#7d39ff",
#         "requiresCredentialStorage": false,
#         "requiresCustomerIpAddress": false,
#         "sandbox": true,
#         "secondaryColor": "#3DF2C2",
#         "sharedBrandName": null,
#         "sharedBrandReference": null,
#         "status": "beta"
#       },
#       "id": "2d3d70a4-cb3c-477c-97e1-cbe495b82841",
#       "links": {
#         "self": "https://api.ibanity.com/xs2a/financial-institutions/2d3d70a4-cb3c-477c-97e1-cbe495b82841"
#       },
#       "type": "financialInstitution"
#     },
#     {
#       "attributes": {
#         "authorizationModels": [
#           "detailed",
#           "financialInstitutionOffered"
#         ],
#         "bic": "NBBEBEBB203",
#         "bulkPaymentsEnabled": true,
#         "bulkPaymentsProductTypes": [
#           "sepaCreditTransfer"
#         ],
#         "country": null,
#         "financialInstitutionCustomerReferenceRequired": false,
#         "futureDatedPaymentsAllowed": true,
#         "logoUrl": "https://s3.eu-central-1.amazonaws.com/ibanity-production-financial-institution-assets/sandbox.png",
#         "maintenanceFrom": null,
#         "maintenanceTo": null,
#         "maintenanceType": null,
#         "maxRequestedAccountReferences": null,
#         "minRequestedAccountReferences": 0,
#         "name": "XYZ Trust",
#         "paymentsEnabled": true,
#         "paymentsProductTypes": [
#           "sepaCreditTransfer"
#         ],
#         "periodicPaymentsEnabled": true,
#         "periodicPaymentsProductTypes": [
#           "sepaCreditTransfer"
#         ],
#         "primaryColor": "#7d39ff",
#         "requiresCredentialStorage": false,
#         "requiresCustomerIpAddress": false,
#         "sandbox": true,
#         "secondaryColor": "#3DF2C2",
#         "sharedBrandName": null,
#         "sharedBrandReference": null,
#         "status": "beta"
#       },
#       "id": "d4100f28-936b-4379-a3f8-86314a2014fb",
#       "links": {
#         "self": "https://api.ibanity.com/xs2a/financial-institutions/d4100f28-936b-4379-a3f8-86314a2014fb"
#       },
#       "type": "financialInstitution"
#     }
#   ],
#   "links": {
#     "first": "https://api.ibanity.com/xs2a/financial-institutions"
#   },
#   "meta": {
#     "paging": {
#       "limit": 10
#     }
#   }
# }

# Sample code for parsing the JSON response...
# Use the following online tool to generate parsing code from sample JSON:
# Generate Parsing Code from JSON

set linksFirst [CkJsonObject_stringOf $jResp "links.first"]
set metaPagingLimit [CkJsonObject_IntOf $jResp "meta.paging.limit"]
set i 0
set count_i [CkJsonObject_SizeOfArray $jResp "data"]
while {$i < $count_i} {
    CkJsonObject_put_I $jResp $i
    set attributesBic [CkJsonObject_stringOf $jResp "data[i].attributes.bic"]
    set attributesBulkPaymentsEnabled [CkJsonObject_BoolOf $jResp "data[i].attributes.bulkPaymentsEnabled"]
    set attributesCountry [CkJsonObject_stringOf $jResp "data[i].attributes.country"]
    set attributesFinancialInstitutionCustomerReferenceRequired [CkJsonObject_BoolOf $jResp "data[i].attributes.financialInstitutionCustomerReferenceRequired"]
    set attributesFutureDatedPaymentsAllowed [CkJsonObject_BoolOf $jResp "data[i].attributes.futureDatedPaymentsAllowed"]
    set attributesLogoUrl [CkJsonObject_stringOf $jResp "data[i].attributes.logoUrl"]
    set attributesMaintenanceFrom [CkJsonObject_stringOf $jResp "data[i].attributes.maintenanceFrom"]
    set attributesMaintenanceTo [CkJsonObject_stringOf $jResp "data[i].attributes.maintenanceTo"]
    set attributesMaintenanceType [CkJsonObject_stringOf $jResp "data[i].attributes.maintenanceType"]
    set attributesMaxRequestedAccountReferences [CkJsonObject_stringOf $jResp "data[i].attributes.maxRequestedAccountReferences"]
    set attributesMinRequestedAccountReferences [CkJsonObject_IntOf $jResp "data[i].attributes.minRequestedAccountReferences"]
    set attributesName [CkJsonObject_stringOf $jResp "data[i].attributes.name"]
    set attributesPaymentsEnabled [CkJsonObject_BoolOf $jResp "data[i].attributes.paymentsEnabled"]
    set attributesPeriodicPaymentsEnabled [CkJsonObject_BoolOf $jResp "data[i].attributes.periodicPaymentsEnabled"]
    set attributesPrimaryColor [CkJsonObject_stringOf $jResp "data[i].attributes.primaryColor"]
    set attributesRequiresCredentialStorage [CkJsonObject_BoolOf $jResp "data[i].attributes.requiresCredentialStorage"]
    set attributesRequiresCustomerIpAddress [CkJsonObject_BoolOf $jResp "data[i].attributes.requiresCustomerIpAddress"]
    set attributesSandbox [CkJsonObject_BoolOf $jResp "data[i].attributes.sandbox"]
    set attributesSecondaryColor [CkJsonObject_stringOf $jResp "data[i].attributes.secondaryColor"]
    set attributesSharedBrandName [CkJsonObject_stringOf $jResp "data[i].attributes.sharedBrandName"]
    set attributesSharedBrandReference [CkJsonObject_stringOf $jResp "data[i].attributes.sharedBrandReference"]
    set attributesStatus [CkJsonObject_stringOf $jResp "data[i].attributes.status"]
    set id [CkJsonObject_stringOf $jResp "data[i].id"]
    set linksSelf [CkJsonObject_stringOf $jResp "data[i].links.self"]
    set v_type [CkJsonObject_stringOf $jResp "data[i].type"]
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "data[i].attributes.authorizationModels"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "data[i].attributes.authorizationModels[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "data[i].attributes.bulkPaymentsProductTypes"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "data[i].attributes.bulkPaymentsProductTypes[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "data[i].attributes.paymentsProductTypes"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "data[i].attributes.paymentsProductTypes[j]"]
        set j [expr $j + 1]
    }
    set j 0
    set count_j [CkJsonObject_SizeOfArray $jResp "data[i].attributes.periodicPaymentsProductTypes"]
    while {$j < $count_j} {
        CkJsonObject_put_J $jResp $j
        set strVal [CkJsonObject_stringOf $jResp "data[i].attributes.periodicPaymentsProductTypes[j]"]
        set j [expr $j + 1]
    }
    set i [expr $i + 1]
}

delete_CkCert $cert
delete_CkDateTime $dtNow
delete_CkCrypt2 $crypt2
delete_CkStringBuilder $sbDigestHdrValue
delete_CkStringBuilder $sbSigningString
delete_CkPrivateKey $privKey
delete_CkRsa $rsa
delete_CkStringBuilder $sbSigHeaderValue
delete_CkHttp $http
delete_CkStringBuilder $sbResponseBody
delete_CkJsonObject $jResp

 

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