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
(VB.NET) Ibanity XS2A List Financial InstitutionsSee more Ibanity ExamplesDemonstrates how to send a request to get a list of financial institutions. For more information, see https://documentation.ibanity.com/xs2a/api/curl#authentication
' 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.) Dim cert As New Chilkat.Cert Dim success As Boolean = cert.LoadPfxFile("qa_data/pfx/my_ibanity_certificate.pfx","my_pfx_password") If (success = False) Then Debug.WriteLine(cert.LastErrorText) Exit Sub End If ' 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. Dim dtNow As New Chilkat.CkDateTime dtNow.SetFromCurrentSystemTime() Dim created As String = dtNow.GetAsUnixTimeStr(False) Dim crypt2 As New Chilkat.Crypt2 crypt2.HashAlgorithm = "sha512" crypt2.EncodingMode = "base64" Dim sbDigestHdrValue As New Chilkat.StringBuilder sbDigestHdrValue.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. sbDigestHdrValue.Append(crypt2.HashStringENC("")) Debug.WriteLine("Generated Digest") Debug.WriteLine(sbDigestHdrValue.GetAsString()) Dim request_target As String = "get /xs2a/financial-institutions" Dim sbSigningString As New Chilkat.StringBuilder sbSigningString.Append("(request-target): ") sbSigningString.AppendLine(request_target,False) sbSigningString.Append("host: ") sbSigningString.AppendLine("api.ibanity.com",False) sbSigningString.Append("digest: ") sbSigningString.AppendLine(sbDigestHdrValue.GetAsString(),False) sbSigningString.Append("(created): ") sbSigningString.Append(created) ' ibanity-idempotency-key is not used with GET requests. Debug.WriteLine("Signing String:") Debug.WriteLine(sbSigningString.GetAsString()) Dim signed_headers_list As String = "(request-target) host digest (created)" Dim privKey As New Chilkat.PrivateKey success = privKey.LoadEncryptedPemFile("my_ibanity_signature_private_key.pem","pem_password") If (success = False) Then Debug.WriteLine(privKey.LastErrorText) Exit Sub End If Dim rsa As New Chilkat.Rsa rsa.PssSaltLen = 32 rsa.EncodingMode = "base64" ' Use the RSASSA-PSS signature algorithm rsa.OaepPadding = True success = rsa.ImportPrivateKeyObj(privKey) If (success = False) Then Debug.WriteLine(rsa.LastErrorText) Exit Sub End If ' Sign the signing string. Dim sigBase64 As String = rsa.SignStringENC(sbSigningString.GetAsString(),"sha-256") If (rsa.LastMethodSuccess = False) Then Debug.WriteLine(rsa.LastErrorText) Exit Sub End If Debug.WriteLine("Signature:") Debug.WriteLine(sigBase64) ' Build the signature header value. Dim sbSigHeaderValue As New Chilkat.StringBuilder sbSigHeaderValue.Append("keyId=""") ' Use your identifier for the application's signature certificate, obtained from the Developer Portal sbSigHeaderValue.Append("a0ce296d-84c8-4bd5-8eb4-de0339950cfa") sbSigHeaderValue.Append(""",created=") sbSigHeaderValue.Append(created) sbSigHeaderValue.Append(",algorithm=""hs2019"",headers=""") sbSigHeaderValue.Append(signed_headers_list) sbSigHeaderValue.Append(""",signature=""") sbSigHeaderValue.Append(sigBase64) sbSigHeaderValue.Append("""") ' Send the GET request.. Dim http As New Chilkat.Http success = http.SetSslClientCert(cert) If (success = False) Then Debug.WriteLine(http.LastErrorText) Exit Sub End If http.SetRequestHeader("Signature",sbSigHeaderValue.GetAsString()) http.SetRequestHeader("Digest",sbDigestHdrValue.GetAsString()) Dim sbResponseBody As New Chilkat.StringBuilder success = http.QuickGetSb("https://api.ibanity.com/xs2a/financial-institutions",sbResponseBody) If (success = False) Then Debug.WriteLine(http.LastErrorText) Exit Sub End If Dim jResp As New Chilkat.JsonObject jResp.LoadSb(sbResponseBody) jResp.EmitCompact = False Debug.WriteLine("Response Body:") Debug.WriteLine(jResp.Emit()) Dim respStatusCode As Integer = http.LastStatus Debug.WriteLine("Response Status Code = " & respStatusCode) If (respStatusCode >= 400) Then Debug.WriteLine("Response Header:") Debug.WriteLine(http.LastHeader) Debug.WriteLine("Failed.") Exit Sub End If ' 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 Dim attributesBic As String Dim attributesBulkPaymentsEnabled As Boolean Dim attributesCountry As String Dim attributesFinancialInstitutionCustomerReferenceRequired As Boolean Dim attributesFutureDatedPaymentsAllowed As Boolean Dim attributesLogoUrl As String Dim attributesMaintenanceFrom As String Dim attributesMaintenanceTo As String Dim attributesMaintenanceType As String Dim attributesMaxRequestedAccountReferences As String Dim attributesMinRequestedAccountReferences As Integer Dim attributesName As String Dim attributesPaymentsEnabled As Boolean Dim attributesPeriodicPaymentsEnabled As Boolean Dim attributesPrimaryColor As String Dim attributesRequiresCredentialStorage As Boolean Dim attributesRequiresCustomerIpAddress As Boolean Dim attributesSandbox As Boolean Dim attributesSecondaryColor As String Dim attributesSharedBrandName As String Dim attributesSharedBrandReference As String Dim attributesStatus As String Dim id As String Dim linksSelf As String Dim v_type As String Dim j As Integer Dim count_j As Integer Dim strVal As String Dim linksFirst As String = jResp.StringOf("links.first") Dim metaPagingLimit As Integer = jResp.IntOf("meta.paging.limit") Dim i As Integer = 0 Dim count_i As Integer = jResp.SizeOfArray("data") While i < count_i jResp.I = i attributesBic = jResp.StringOf("data[i].attributes.bic") attributesBulkPaymentsEnabled = jResp.BoolOf("data[i].attributes.bulkPaymentsEnabled") attributesCountry = jResp.StringOf("data[i].attributes.country") attributesFinancialInstitutionCustomerReferenceRequired = jResp.BoolOf("data[i].attributes.financialInstitutionCustomerReferenceRequired") attributesFutureDatedPaymentsAllowed = jResp.BoolOf("data[i].attributes.futureDatedPaymentsAllowed") attributesLogoUrl = jResp.StringOf("data[i].attributes.logoUrl") attributesMaintenanceFrom = jResp.StringOf("data[i].attributes.maintenanceFrom") attributesMaintenanceTo = jResp.StringOf("data[i].attributes.maintenanceTo") attributesMaintenanceType = jResp.StringOf("data[i].attributes.maintenanceType") attributesMaxRequestedAccountReferences = jResp.StringOf("data[i].attributes.maxRequestedAccountReferences") attributesMinRequestedAccountReferences = jResp.IntOf("data[i].attributes.minRequestedAccountReferences") attributesName = jResp.StringOf("data[i].attributes.name") attributesPaymentsEnabled = jResp.BoolOf("data[i].attributes.paymentsEnabled") attributesPeriodicPaymentsEnabled = jResp.BoolOf("data[i].attributes.periodicPaymentsEnabled") attributesPrimaryColor = jResp.StringOf("data[i].attributes.primaryColor") attributesRequiresCredentialStorage = jResp.BoolOf("data[i].attributes.requiresCredentialStorage") attributesRequiresCustomerIpAddress = jResp.BoolOf("data[i].attributes.requiresCustomerIpAddress") attributesSandbox = jResp.BoolOf("data[i].attributes.sandbox") attributesSecondaryColor = jResp.StringOf("data[i].attributes.secondaryColor") attributesSharedBrandName = jResp.StringOf("data[i].attributes.sharedBrandName") attributesSharedBrandReference = jResp.StringOf("data[i].attributes.sharedBrandReference") attributesStatus = jResp.StringOf("data[i].attributes.status") id = jResp.StringOf("data[i].id") linksSelf = jResp.StringOf("data[i].links.self") v_type = jResp.StringOf("data[i].type") j = 0 count_j = jResp.SizeOfArray("data[i].attributes.authorizationModels") While j < count_j jResp.J = j strVal = jResp.StringOf("data[i].attributes.authorizationModels[j]") j = j + 1 End While j = 0 count_j = jResp.SizeOfArray("data[i].attributes.bulkPaymentsProductTypes") While j < count_j jResp.J = j strVal = jResp.StringOf("data[i].attributes.bulkPaymentsProductTypes[j]") j = j + 1 End While j = 0 count_j = jResp.SizeOfArray("data[i].attributes.paymentsProductTypes") While j < count_j jResp.J = j strVal = jResp.StringOf("data[i].attributes.paymentsProductTypes[j]") j = j + 1 End While j = 0 count_j = jResp.SizeOfArray("data[i].attributes.periodicPaymentsProductTypes") While j < count_j jResp.J = j strVal = jResp.StringOf("data[i].attributes.periodicPaymentsProductTypes[j]") j = j + 1 End While i = i + 1 End While |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.