Sample code for 30+ languages & platforms
AutoIt

Ibanity XS2A List Financial Institutions

See more Ibanity Examples

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

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; 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.)
$oCert = ObjCreate("Chilkat.Cert")
$bSuccess = $oCert.LoadPfxFile("qa_data/pfx/my_ibanity_certificate.pfx","my_pfx_password")
If ($bSuccess = False) Then
    ConsoleWrite($oCert.LastErrorText & @CRLF)
    Exit
EndIf

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

$oDtNow = ObjCreate("Chilkat.CkDateTime")
$oDtNow.SetFromCurrentSystemTime()
Local $sCreated = $oDtNow.GetAsUnixTimeStr(False)

$oCrypt2 = ObjCreate("Chilkat.Crypt2")
$oCrypt2.HashAlgorithm = "sha512"
$oCrypt2.EncodingMode = "base64"

$oSbDigestHdrValue = ObjCreate("Chilkat.StringBuilder")
$oSbDigestHdrValue.Append("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.
$oSbDigestHdrValue.Append($oCrypt2.HashStringENC(""))

ConsoleWrite("Generated Digest" & @CRLF)
ConsoleWrite($oSbDigestHdrValue.GetAsString() & @CRLF)

Local $sRequest_target = "get /xs2a/financial-institutions"

$oSbSigningString = ObjCreate("Chilkat.StringBuilder")
$oSbSigningString.Append("(request-target): ")
$oSbSigningString.AppendLine($sRequest_target,False)
$oSbSigningString.Append("host: ")
$oSbSigningString.AppendLine("api.ibanity.com",False)
$oSbSigningString.Append("digest: ")
$oSbSigningString.AppendLine($oSbDigestHdrValue.GetAsString(),False)
$oSbSigningString.Append("(created): ")
$oSbSigningString.Append($sCreated)
; ibanity-idempotency-key is not used with GET requests.

ConsoleWrite("Signing String:" & @CRLF)
ConsoleWrite($oSbSigningString.GetAsString() & @CRLF)

Local $signed_headers_list = "(request-target) host digest (created)"

$oPrivKey = ObjCreate("Chilkat.PrivateKey")
$bSuccess = $oPrivKey.LoadEncryptedPemFile("my_ibanity_signature_private_key.pem","pem_password")
If ($bSuccess = False) Then
    ConsoleWrite($oPrivKey.LastErrorText & @CRLF)
    Exit
EndIf

$oRsa = ObjCreate("Chilkat.Rsa")
$oRsa.PssSaltLen = 32
$oRsa.EncodingMode = "base64"
; Use the RSASSA-PSS signature algorithm
$oRsa.PkcsPadding = False

$bSuccess = $oRsa.UsePrivateKey($oPrivKey)
If ($bSuccess = False) Then
    ConsoleWrite($oRsa.LastErrorText & @CRLF)
    Exit
EndIf

; Sign the signing string.
Local $sigBase64 = $oRsa.SignStringENC($oSbSigningString.GetAsString(),"sha-256")
If ($oRsa.LastMethodSuccess = False) Then
    ConsoleWrite($oRsa.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Signature:" & @CRLF)
ConsoleWrite($sigBase64 & @CRLF)

; Build the signature header value.
$oSbSigHeaderValue = ObjCreate("Chilkat.StringBuilder")
$oSbSigHeaderValue.Append("keyId=""")
; Use your identifier for the application's signature certificate, obtained from the Developer Portal
$oSbSigHeaderValue.Append("a0ce296d-84c8-4bd5-8eb4-de0339950cfa")
$oSbSigHeaderValue.Append(""",created=")
$oSbSigHeaderValue.Append($sCreated)
$oSbSigHeaderValue.Append(",algorithm=""hs2019"",headers=""")
$oSbSigHeaderValue.Append($signed_headers_list)
$oSbSigHeaderValue.Append(""",signature=""")
$oSbSigHeaderValue.Append($sigBase64)
$oSbSigHeaderValue.Append("""")

; Send the GET request..
$oHttp = ObjCreate("Chilkat.Http")

$bSuccess = $oHttp.SetSslClientCert($oCert)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oHttp.SetRequestHeader "Signature",$oSbSigHeaderValue.GetAsString()
$oHttp.SetRequestHeader "Digest",$oSbDigestHdrValue.GetAsString()

$oSbResponseBody = ObjCreate("Chilkat.StringBuilder")
$bSuccess = $oHttp.QuickGetSb("https://api.ibanity.com/xs2a/financial-institutions",$oSbResponseBody)
If ($bSuccess = False) Then
    ConsoleWrite($oHttp.LastErrorText & @CRLF)
    Exit
EndIf

$oJResp = ObjCreate("Chilkat.JsonObject")
$oJResp.LoadSb($oSbResponseBody)
$oJResp.EmitCompact = False

ConsoleWrite("Response Body:" & @CRLF)
ConsoleWrite($oJResp.Emit() & @CRLF)

Local $iRespStatusCode = $oHttp.LastStatus
ConsoleWrite("Response Status Code = " & $iRespStatusCode & @CRLF)
If ($iRespStatusCode >= 400) Then
    ConsoleWrite("Response Header:" & @CRLF)
    ConsoleWrite($oHttp.LastHeader & @CRLF)
    ConsoleWrite("Failed." & @CRLF)
    Exit
EndIf

; 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

Local $sAttributesBic
Local $bAttributesBulkPaymentsEnabled
Local $sAttributesCountry
Local $bAttributesFinancialInstitutionCustomerReferenceRequired
Local $bAttributesFutureDatedPaymentsAllowed
Local $sAttributesLogoUrl
Local $sAttributesMaintenanceFrom
Local $sAttributesMaintenanceTo
Local $sAttributesMaintenanceType
Local $sAttributesMaxRequestedAccountReferences
Local $iAttributesMinRequestedAccountReferences
Local $sAttributesName
Local $bAttributesPaymentsEnabled
Local $bAttributesPeriodicPaymentsEnabled
Local $sAttributesPrimaryColor
Local $bAttributesRequiresCredentialStorage
Local $bAttributesRequiresCustomerIpAddress
Local $bAttributesSandbox
Local $sAttributesSecondaryColor
Local $sAttributesSharedBrandName
Local $sAttributesSharedBrandReference
Local $sAttributesStatus
Local $sId
Local $sLinksSelf
Local $sV_type
Local $iJ
Local $iCount_j
Local $strVal

Local $sLinksFirst = $oJResp.StringOf("links.first")
Local $iMetaPagingLimit = $oJResp.IntOf("meta.paging.limit")
Local $i = 0
Local $iCount_i = $oJResp.SizeOfArray("data")
While $i < $iCount_i
    $oJResp.I = $i
    $sAttributesBic = $oJResp.StringOf("data[i].attributes.bic")
    $bAttributesBulkPaymentsEnabled = $oJResp.BoolOf("data[i].attributes.bulkPaymentsEnabled")
    $sAttributesCountry = $oJResp.StringOf("data[i].attributes.country")
    $bAttributesFinancialInstitutionCustomerReferenceRequired = $oJResp.BoolOf("data[i].attributes.financialInstitutionCustomerReferenceRequired")
    $bAttributesFutureDatedPaymentsAllowed = $oJResp.BoolOf("data[i].attributes.futureDatedPaymentsAllowed")
    $sAttributesLogoUrl = $oJResp.StringOf("data[i].attributes.logoUrl")
    $sAttributesMaintenanceFrom = $oJResp.StringOf("data[i].attributes.maintenanceFrom")
    $sAttributesMaintenanceTo = $oJResp.StringOf("data[i].attributes.maintenanceTo")
    $sAttributesMaintenanceType = $oJResp.StringOf("data[i].attributes.maintenanceType")
    $sAttributesMaxRequestedAccountReferences = $oJResp.StringOf("data[i].attributes.maxRequestedAccountReferences")
    $iAttributesMinRequestedAccountReferences = $oJResp.IntOf("data[i].attributes.minRequestedAccountReferences")
    $sAttributesName = $oJResp.StringOf("data[i].attributes.name")
    $bAttributesPaymentsEnabled = $oJResp.BoolOf("data[i].attributes.paymentsEnabled")
    $bAttributesPeriodicPaymentsEnabled = $oJResp.BoolOf("data[i].attributes.periodicPaymentsEnabled")
    $sAttributesPrimaryColor = $oJResp.StringOf("data[i].attributes.primaryColor")
    $bAttributesRequiresCredentialStorage = $oJResp.BoolOf("data[i].attributes.requiresCredentialStorage")
    $bAttributesRequiresCustomerIpAddress = $oJResp.BoolOf("data[i].attributes.requiresCustomerIpAddress")
    $bAttributesSandbox = $oJResp.BoolOf("data[i].attributes.sandbox")
    $sAttributesSecondaryColor = $oJResp.StringOf("data[i].attributes.secondaryColor")
    $sAttributesSharedBrandName = $oJResp.StringOf("data[i].attributes.sharedBrandName")
    $sAttributesSharedBrandReference = $oJResp.StringOf("data[i].attributes.sharedBrandReference")
    $sAttributesStatus = $oJResp.StringOf("data[i].attributes.status")
    $sId = $oJResp.StringOf("data[i].id")
    $sLinksSelf = $oJResp.StringOf("data[i].links.self")
    $sV_type = $oJResp.StringOf("data[i].type")
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("data[i].attributes.authorizationModels")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("data[i].attributes.authorizationModels[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("data[i].attributes.bulkPaymentsProductTypes")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("data[i].attributes.bulkPaymentsProductTypes[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("data[i].attributes.paymentsProductTypes")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("data[i].attributes.paymentsProductTypes[j]")
        $iJ = $iJ + 1
    Wend
    $iJ = 0
    $iCount_j = $oJResp.SizeOfArray("data[i].attributes.periodicPaymentsProductTypes")
    While $iJ < $iCount_j
        $oJResp.J = $iJ
        $strVal = $oJResp.StringOf("data[i].attributes.periodicPaymentsProductTypes[j]")
        $iJ = $iJ + 1
    Wend
    $i = $i + 1
Wend