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
(PowerBuilder) 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
integer li_rc oleobject loo_Cert integer li_Success oleobject loo_DtNow string ls_Created oleobject loo_Crypt2 oleobject loo_SbDigestHdrValue string ls_Request_target oleobject loo_SbSigningString string ls_Signed_headers_list oleobject loo_PrivKey oleobject loo_Rsa string ls_SigBase64 oleobject loo_SbSigHeaderValue oleobject loo_Http oleobject loo_SbResponseBody oleobject loo_JResp integer li_RespStatusCode string ls_AttributesBic integer li_AttributesBulkPaymentsEnabled string ls_AttributesCountry integer li_AttributesFinancialInstitutionCustomerReferenceRequired integer li_AttributesFutureDatedPaymentsAllowed string ls_AttributesLogoUrl string ls_AttributesMaintenanceFrom string ls_AttributesMaintenanceTo string ls_AttributesMaintenanceType string ls_AttributesMaxRequestedAccountReferences integer li_AttributesMinRequestedAccountReferences string ls_AttributesName integer li_AttributesPaymentsEnabled integer li_AttributesPeriodicPaymentsEnabled string ls_AttributesPrimaryColor integer li_AttributesRequiresCredentialStorage integer li_AttributesRequiresCustomerIpAddress integer li_AttributesSandbox string ls_AttributesSecondaryColor string ls_AttributesSharedBrandName string ls_AttributesSharedBrandReference string ls_AttributesStatus string ls_Id string ls_LinksSelf string ls_V_type integer j integer li_Count_j string ls_StrVal string ls_LinksFirst integer li_MetaPagingLimit integer i integer li_Count_i // 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.) loo_Cert = create oleobject // Use "Chilkat_9_5_0.Cert" for versions of Chilkat < 10.0.0 li_rc = loo_Cert.ConnectToNewObject("Chilkat.Cert") if li_rc < 0 then destroy loo_Cert MessageBox("Error","Connecting to COM object failed") return end if li_Success = loo_Cert.LoadPfxFile("qa_data/pfx/my_ibanity_certificate.pfx","my_pfx_password") if li_Success = 0 then Write-Debug loo_Cert.LastErrorText destroy loo_Cert return 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. loo_DtNow = create oleobject // Use "Chilkat_9_5_0.CkDateTime" for versions of Chilkat < 10.0.0 li_rc = loo_DtNow.ConnectToNewObject("Chilkat.CkDateTime") loo_DtNow.SetFromCurrentSystemTime() ls_Created = loo_DtNow.GetAsUnixTimeStr(0) loo_Crypt2 = create oleobject // Use "Chilkat_9_5_0.Crypt2" for versions of Chilkat < 10.0.0 li_rc = loo_Crypt2.ConnectToNewObject("Chilkat.Crypt2") loo_Crypt2.HashAlgorithm = "sha512" loo_Crypt2.EncodingMode = "base64" loo_SbDigestHdrValue = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbDigestHdrValue.ConnectToNewObject("Chilkat.StringBuilder") loo_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. loo_SbDigestHdrValue.Append(loo_Crypt2.HashStringENC("")) Write-Debug "Generated Digest" Write-Debug loo_SbDigestHdrValue.GetAsString() ls_Request_target = "get /xs2a/financial-institutions" loo_SbSigningString = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbSigningString.ConnectToNewObject("Chilkat.StringBuilder") loo_SbSigningString.Append("(request-target): ") loo_SbSigningString.AppendLine(ls_Request_target,0) loo_SbSigningString.Append("host: ") loo_SbSigningString.AppendLine("api.ibanity.com",0) loo_SbSigningString.Append("digest: ") loo_SbSigningString.AppendLine(loo_SbDigestHdrValue.GetAsString(),0) loo_SbSigningString.Append("(created): ") loo_SbSigningString.Append(ls_Created) // ibanity-idempotency-key is not used with GET requests. Write-Debug "Signing String:" Write-Debug loo_SbSigningString.GetAsString() ls_Signed_headers_list = "(request-target) host digest (created)" loo_PrivKey = create oleobject // Use "Chilkat_9_5_0.PrivateKey" for versions of Chilkat < 10.0.0 li_rc = loo_PrivKey.ConnectToNewObject("Chilkat.PrivateKey") li_Success = loo_PrivKey.LoadEncryptedPemFile("my_ibanity_signature_private_key.pem","pem_password") if li_Success = 0 then Write-Debug loo_PrivKey.LastErrorText destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey return end if loo_Rsa = create oleobject // Use "Chilkat_9_5_0.Rsa" for versions of Chilkat < 10.0.0 li_rc = loo_Rsa.ConnectToNewObject("Chilkat.Rsa") loo_Rsa.PssSaltLen = 32 loo_Rsa.EncodingMode = "base64" // Use the RSASSA-PSS signature algorithm loo_Rsa.OaepPadding = 1 li_Success = loo_Rsa.ImportPrivateKeyObj(loo_PrivKey) if li_Success = 0 then Write-Debug loo_Rsa.LastErrorText destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey destroy loo_Rsa return end if // Sign the signing string. ls_SigBase64 = loo_Rsa.SignStringENC(loo_SbSigningString.GetAsString(),"sha-256") if loo_Rsa.LastMethodSuccess = 0 then Write-Debug loo_Rsa.LastErrorText destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey destroy loo_Rsa return end if Write-Debug "Signature:" Write-Debug ls_SigBase64 // Build the signature header value. loo_SbSigHeaderValue = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbSigHeaderValue.ConnectToNewObject("Chilkat.StringBuilder") loo_SbSigHeaderValue.Append("keyId=~"") // Use your identifier for the application's signature certificate, obtained from the Developer Portal loo_SbSigHeaderValue.Append("a0ce296d-84c8-4bd5-8eb4-de0339950cfa") loo_SbSigHeaderValue.Append("~",created=") loo_SbSigHeaderValue.Append(ls_Created) loo_SbSigHeaderValue.Append(",algorithm=~"hs2019~",headers=~"") loo_SbSigHeaderValue.Append(ls_Signed_headers_list) loo_SbSigHeaderValue.Append("~",signature=~"") loo_SbSigHeaderValue.Append(ls_SigBase64) loo_SbSigHeaderValue.Append("~"") // Send the GET request.. loo_Http = create oleobject // Use "Chilkat_9_5_0.Http" for versions of Chilkat < 10.0.0 li_rc = loo_Http.ConnectToNewObject("Chilkat.Http") li_Success = loo_Http.SetSslClientCert(loo_Cert) if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey destroy loo_Rsa destroy loo_SbSigHeaderValue destroy loo_Http return end if loo_Http.SetRequestHeader("Signature",loo_SbSigHeaderValue.GetAsString()) loo_Http.SetRequestHeader("Digest",loo_SbDigestHdrValue.GetAsString()) loo_SbResponseBody = create oleobject // Use "Chilkat_9_5_0.StringBuilder" for versions of Chilkat < 10.0.0 li_rc = loo_SbResponseBody.ConnectToNewObject("Chilkat.StringBuilder") li_Success = loo_Http.QuickGetSb("https://api.ibanity.com/xs2a/financial-institutions",loo_SbResponseBody) if li_Success = 0 then Write-Debug loo_Http.LastErrorText destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey destroy loo_Rsa destroy loo_SbSigHeaderValue destroy loo_Http destroy loo_SbResponseBody return end if loo_JResp = create oleobject // Use "Chilkat_9_5_0.JsonObject" for versions of Chilkat < 10.0.0 li_rc = loo_JResp.ConnectToNewObject("Chilkat.JsonObject") loo_JResp.LoadSb(loo_SbResponseBody) loo_JResp.EmitCompact = 0 Write-Debug "Response Body:" Write-Debug loo_JResp.Emit() li_RespStatusCode = loo_Http.LastStatus Write-Debug "Response Status Code = " + string(li_RespStatusCode) if li_RespStatusCode >= 400 then Write-Debug "Response Header:" Write-Debug loo_Http.LastHeader Write-Debug "Failed." destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey destroy loo_Rsa destroy loo_SbSigHeaderValue destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp return 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 ls_LinksFirst = loo_JResp.StringOf("links.first") li_MetaPagingLimit = loo_JResp.IntOf("meta.paging.limit") i = 0 li_Count_i = loo_JResp.SizeOfArray("data") do while i < li_Count_i loo_JResp.I = i ls_AttributesBic = loo_JResp.StringOf("data[i].attributes.bic") li_AttributesBulkPaymentsEnabled = loo_JResp.BoolOf("data[i].attributes.bulkPaymentsEnabled") ls_AttributesCountry = loo_JResp.StringOf("data[i].attributes.country") li_AttributesFinancialInstitutionCustomerReferenceRequired = loo_JResp.BoolOf("data[i].attributes.financialInstitutionCustomerReferenceRequired") li_AttributesFutureDatedPaymentsAllowed = loo_JResp.BoolOf("data[i].attributes.futureDatedPaymentsAllowed") ls_AttributesLogoUrl = loo_JResp.StringOf("data[i].attributes.logoUrl") ls_AttributesMaintenanceFrom = loo_JResp.StringOf("data[i].attributes.maintenanceFrom") ls_AttributesMaintenanceTo = loo_JResp.StringOf("data[i].attributes.maintenanceTo") ls_AttributesMaintenanceType = loo_JResp.StringOf("data[i].attributes.maintenanceType") ls_AttributesMaxRequestedAccountReferences = loo_JResp.StringOf("data[i].attributes.maxRequestedAccountReferences") li_AttributesMinRequestedAccountReferences = loo_JResp.IntOf("data[i].attributes.minRequestedAccountReferences") ls_AttributesName = loo_JResp.StringOf("data[i].attributes.name") li_AttributesPaymentsEnabled = loo_JResp.BoolOf("data[i].attributes.paymentsEnabled") li_AttributesPeriodicPaymentsEnabled = loo_JResp.BoolOf("data[i].attributes.periodicPaymentsEnabled") ls_AttributesPrimaryColor = loo_JResp.StringOf("data[i].attributes.primaryColor") li_AttributesRequiresCredentialStorage = loo_JResp.BoolOf("data[i].attributes.requiresCredentialStorage") li_AttributesRequiresCustomerIpAddress = loo_JResp.BoolOf("data[i].attributes.requiresCustomerIpAddress") li_AttributesSandbox = loo_JResp.BoolOf("data[i].attributes.sandbox") ls_AttributesSecondaryColor = loo_JResp.StringOf("data[i].attributes.secondaryColor") ls_AttributesSharedBrandName = loo_JResp.StringOf("data[i].attributes.sharedBrandName") ls_AttributesSharedBrandReference = loo_JResp.StringOf("data[i].attributes.sharedBrandReference") ls_AttributesStatus = loo_JResp.StringOf("data[i].attributes.status") ls_Id = loo_JResp.StringOf("data[i].id") ls_LinksSelf = loo_JResp.StringOf("data[i].links.self") ls_V_type = loo_JResp.StringOf("data[i].type") j = 0 li_Count_j = loo_JResp.SizeOfArray("data[i].attributes.authorizationModels") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("data[i].attributes.authorizationModels[j]") j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("data[i].attributes.bulkPaymentsProductTypes") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("data[i].attributes.bulkPaymentsProductTypes[j]") j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("data[i].attributes.paymentsProductTypes") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("data[i].attributes.paymentsProductTypes[j]") j = j + 1 loop j = 0 li_Count_j = loo_JResp.SizeOfArray("data[i].attributes.periodicPaymentsProductTypes") do while j < li_Count_j loo_JResp.J = j ls_StrVal = loo_JResp.StringOf("data[i].attributes.periodicPaymentsProductTypes[j]") j = j + 1 loop i = i + 1 loop destroy loo_Cert destroy loo_DtNow destroy loo_Crypt2 destroy loo_SbDigestHdrValue destroy loo_SbSigningString destroy loo_PrivKey destroy loo_Rsa destroy loo_SbSigHeaderValue destroy loo_Http destroy loo_SbResponseBody destroy loo_JResp |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.