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

Swift 3,4,5... Web API Examples

Primary Categories

ABN AMRO
AWS Secrets Manager
AWS Security Token Service
AWS Translate
Activix CRM
Adyen
Alibaba Cloud OSS
Amazon Cognito
Amazon DynamoDB
Amazon MWS
Amazon Pay
Amazon Rekognition
Amazon SP-API
Amazon Voice ID
Aruba Fatturazione
Azure Maps
Azure Monitor
Azure OAuth2
Azure Storage Accounts
Backblaze S3
Banco Inter
Belgian eHealth Platform
Bitfinex v2 REST
Bluzone
BrickLink
Bunny CDN
CallRail
CardConnect
Cerved
ClickBank
Clickatell
Cloudfare
Constant Contact
DocuSign
Duo Auth MFA
ETrade
Ecwid
Egypt ITIDA
Egypt eReceipt
Etsy
Facebook
Faire
Frame.io
GeoOp
GetHarvest
Global Payments
Google People
Google Search Console
Google Translate
Google Vision
Hungary NAV Invoicing
IBM Text to Speech
Ibanity
IntakeQ
JCC Cyprus
Jira
Lightspeed
MYOB
Magento
Mailgun
Malaysia MyInvois

Mastercard
MedTunnel
MercadoLibre
MessageMedia
Microsoft Calendar
Microsoft Group
Microsoft Tasks and Plans
Microsoft Teams
Moody's
Okta OAuth/OIDC
OneLogin OIDC
OneNote
OpenAI ChatGPT
PRODA
PayPal
Paynow.pl
Peoplevox
Populi
QuickBooks
Rabobank
Refinitiv
Royal Mail OBA
SCiS Schools Catalogue
SII Chile
SMSAPI
SOAP finkok.com
Salesforce
SendGrid
Shippo
Shopify
Shopware
Shopware 6
SimpleTexting
Square
Stripe
SugarCRM
TicketBAI
TikTok Shop
Trello
Twilio
Twitter API v2
Twitter v1
UPS
UniPin
VoiceBase
Vonage
WaTrend
Walmart v3
Wasabi
WhatsApp
WiX
WooCommerce
WordPress
Xero
Yahoo Mail
Yapily
Yousign
ZATCA
Zendesk
Zoom
_Miscellaneous_
eBay
effectconnect
hacienda.go.cr

 

 

 

(Swift 3,4,5...) 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 Downloads for the Swift Programming Language

MAC OS X (Cocoa) Objective-C/Swift Libs

iOS Objective-C/Swift Libs

func chilkatTest() {
    // 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.)
    let cert = CkoCert()!
    var success: Bool = cert.loadPfxFile("qa_data/pfx/my_ibanity_certificate.pfx", password: "my_pfx_password")
    if success == false {
        print("\(cert.lastErrorText!)")
        return
    }

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

    let dtNow = CkoDateTime()!
    dtNow.setFromCurrentSystemTime()
    var created: String? = dtNow.getAsUnixTimeStr(false)

    let crypt2 = CkoCrypt2()!
    crypt2.hashAlgorithm = "sha512"
    crypt2.encodingMode = "base64"

    let sbDigestHdrValue = CkoStringBuilder()!
    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(""))

    print("Generated Digest")
    print("\(sbDigestHdrValue.getAsString()!)")

    var request_target: String? = "get /xs2a/financial-institutions"

    let sbSigningString = CkoStringBuilder()!
    sbSigningString.append("(request-target): ")
    sbSigningString.appendLine(request_target, crlf: false)
    sbSigningString.append("host: ")
    sbSigningString.appendLine("api.ibanity.com", crlf: false)
    sbSigningString.append("digest: ")
    sbSigningString.appendLine(sbDigestHdrValue.getAsString(), crlf: false)
    sbSigningString.append("(created): ")
    sbSigningString.append(created)
    // ibanity-idempotency-key is not used with GET requests.

    print("Signing String:")
    print("\(sbSigningString.getAsString()!)")

    var signed_headers_list: String? = "(request-target) host digest (created)"

    let privKey = CkoPrivateKey()!
    success = privKey.loadEncryptedPemFile("my_ibanity_signature_private_key.pem", password: "pem_password")
    if success == false {
        print("\(privKey.lastErrorText!)")
        return
    }

    let rsa = CkoRsa()!
    rsa.pssSaltLen = 32
    rsa.encodingMode = "base64"
    // Use the RSASSA-PSS signature algorithm
    rsa.oaepPadding = true

    success = rsa.importPrivateKeyObj(privKey)
    if success == false {
        print("\(rsa.lastErrorText!)")
        return
    }

    // Sign the signing string.
    var sigBase64: String? = rsa.signStringENC(sbSigningString.getAsString(), hashAlg: "sha-256")
    if rsa.lastMethodSuccess == false {
        print("\(rsa.lastErrorText!)")
        return
    }

    print("Signature:")
    print("\(sigBase64!)")

    // Build the signature header value.
    let sbSigHeaderValue = CkoStringBuilder()!
    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..
    let http = CkoHttp()!

    success = http.setSslClientCert(cert)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    http.setRequestHeader("Signature", value: sbSigHeaderValue.getAsString())
    http.setRequestHeader("Digest", value: sbDigestHdrValue.getAsString())

    let sbResponseBody = CkoStringBuilder()!
    success = http.quickGetSb("https://api.ibanity.com/xs2a/financial-institutions", sbContent: sbResponseBody)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    let jResp = CkoJsonObject()!
    jResp.loadSb(sbResponseBody)
    jResp.emitCompact = false

    print("Response Body:")
    print("\(jResp.emit()!)")

    var respStatusCode: Int = http.lastStatus.intValue
    print("Response Status Code = \(respStatusCode)")
    if respStatusCode >= 400 {
        print("Response Header:")
        print("\(http.lastHeader!)")
        print("Failed.")
        return
    }

    // 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

    var attributesBic: String?
    var attributesBulkPaymentsEnabled: Bool
    var attributesCountry: String?
    var attributesFinancialInstitutionCustomerReferenceRequired: Bool
    var attributesFutureDatedPaymentsAllowed: Bool
    var attributesLogoUrl: String?
    var attributesMaintenanceFrom: String?
    var attributesMaintenanceTo: String?
    var attributesMaintenanceType: String?
    var attributesMaxRequestedAccountReferences: String?
    var attributesMinRequestedAccountReferences: Int
    var attributesName: String?
    var attributesPaymentsEnabled: Bool
    var attributesPeriodicPaymentsEnabled: Bool
    var attributesPrimaryColor: String?
    var attributesRequiresCredentialStorage: Bool
    var attributesRequiresCustomerIpAddress: Bool
    var attributesSandbox: Bool
    var attributesSecondaryColor: String?
    var attributesSharedBrandName: String?
    var attributesSharedBrandReference: String?
    var attributesStatus: String?
    var id: String?
    var linksSelf: String?
    var v_type: String?
    var j: Int
    var count_j: Int
    var strVal: String?

    var linksFirst: String? = jResp.string(of: "links.first")
    var metaPagingLimit: Int = jResp.int(of: "meta.paging.limit").intValue
    var i: Int = 0
    var count_i: Int = jResp.size(ofArray: "data").intValue
    while i < count_i {
        jResp.i = i
        attributesBic = jResp.string(of: "data[i].attributes.bic")
        attributesBulkPaymentsEnabled = jResp.bool(of: "data[i].attributes.bulkPaymentsEnabled")
        attributesCountry = jResp.string(of: "data[i].attributes.country")
        attributesFinancialInstitutionCustomerReferenceRequired = jResp.bool(of: "data[i].attributes.financialInstitutionCustomerReferenceRequired")
        attributesFutureDatedPaymentsAllowed = jResp.bool(of: "data[i].attributes.futureDatedPaymentsAllowed")
        attributesLogoUrl = jResp.string(of: "data[i].attributes.logoUrl")
        attributesMaintenanceFrom = jResp.string(of: "data[i].attributes.maintenanceFrom")
        attributesMaintenanceTo = jResp.string(of: "data[i].attributes.maintenanceTo")
        attributesMaintenanceType = jResp.string(of: "data[i].attributes.maintenanceType")
        attributesMaxRequestedAccountReferences = jResp.string(of: "data[i].attributes.maxRequestedAccountReferences")
        attributesMinRequestedAccountReferences = jResp.int(of: "data[i].attributes.minRequestedAccountReferences").intValue
        attributesName = jResp.string(of: "data[i].attributes.name")
        attributesPaymentsEnabled = jResp.bool(of: "data[i].attributes.paymentsEnabled")
        attributesPeriodicPaymentsEnabled = jResp.bool(of: "data[i].attributes.periodicPaymentsEnabled")
        attributesPrimaryColor = jResp.string(of: "data[i].attributes.primaryColor")
        attributesRequiresCredentialStorage = jResp.bool(of: "data[i].attributes.requiresCredentialStorage")
        attributesRequiresCustomerIpAddress = jResp.bool(of: "data[i].attributes.requiresCustomerIpAddress")
        attributesSandbox = jResp.bool(of: "data[i].attributes.sandbox")
        attributesSecondaryColor = jResp.string(of: "data[i].attributes.secondaryColor")
        attributesSharedBrandName = jResp.string(of: "data[i].attributes.sharedBrandName")
        attributesSharedBrandReference = jResp.string(of: "data[i].attributes.sharedBrandReference")
        attributesStatus = jResp.string(of: "data[i].attributes.status")
        id = jResp.string(of: "data[i].id")
        linksSelf = jResp.string(of: "data[i].links.self")
        v_type = jResp.string(of: "data[i].type")
        j = 0
        count_j = jResp.size(ofArray: "data[i].attributes.authorizationModels").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "data[i].attributes.authorizationModels[j]")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "data[i].attributes.bulkPaymentsProductTypes").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "data[i].attributes.bulkPaymentsProductTypes[j]")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "data[i].attributes.paymentsProductTypes").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "data[i].attributes.paymentsProductTypes[j]")
            j = j + 1
        }

        j = 0
        count_j = jResp.size(ofArray: "data[i].attributes.periodicPaymentsProductTypes").intValue
        while j < count_j {
            jResp.j = j
            strVal = jResp.string(of: "data[i].attributes.periodicPaymentsProductTypes[j]")
            j = j + 1
        }

        i = i + 1
    }


}

 

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