Page 1 of 1

Banking API Integration

Posted: Thu May 30, 2019 9:03 pm
by atitokor
We're using Cyclos 4.11.5 and wish to integrate with a banking API. So we created a System Record Type and a User Record Type. Now we need help with the script to put it all together.

Thanks in advance, especially the Admins who make it a point to address most of our issues...
3.png (71.07 KiB) Viewed 743 times
4.png (69.22 KiB) Viewed 743 times

Re: Banking API Integration

Posted: Mon Jun 17, 2019 4:29 am
by shashank
the custom scripting example for paypal integration can be taken as a reference and you can build your own custom operation as per your need. below is the link for paypal integration. Hope this helps. ... ntegration

Re: Banking API Integration

Posted: Mon Jun 17, 2019 4:07 pm
by atitokor
Yes, thanks for the PayPal scripting example. I'll dive right into it, and come back only if I need any specific help.

Thanks again for your attention.

Re: Banking API Integration

Posted: Tue Jun 25, 2019 12:52 pm
by atitokor
Hello Admins

Now upgraded to version 4.12 and I've been trying a lot to make my banking API integration work, but I'm struggling. Below is what I've been able to do. I need help... I'd be happy to give global admin access if needed.

Thanks very much in advance for your time and attention


1. Created system record type to store the client id and secret
Name: Plaid Authentication
Internal name: plaidAuth
Display style: Single form
Record type fields
Client ID
Internal name: clientId
Data type: Single line text
Required: yes
Client Secret
Internal name: clientSecret
Data type: Single line text
Required: yes
Access Token
Internal name: accessToken
Data type: Single line text
Plaid Public Key
Internal name: publicKey
Data type: Single line text
Plaid Env
Internal name: plaidEnv
Data type: Single selection

Possible Values:

Internal name: sandbox

Internal name: development

Internal name: production
Plaid Country Codes
Internal name: countryCodes
Data type: Multiple selection

Possible Values:

Internal name: us

Internal name: ca

Internal name: fr

Internal name: es

Internal name: gb
Plaid Products
Internal name: plaidProducts
Data type: Multiple selection

Possible Values:

Internal name: auth

Internal name: transactions

Internal name: identity

Internal name: income

Internal name: assets
Internal name: node
Data type: Single line text
2. Created user record type to store each financial institution account link information
Name: Institution Link
Internal name: institutionLink
Display style: List
Show in Menu: yes
Record type fields
Institution Name
Internal name: institutionName
Data type: Single line text
Institution Id
Internal name: institutionId
Data type: Single line text
Item ID
Internal name: itemId
Data type: Single line text
Account Name
Internal name: accountName
Data type: Single line text
Account Type
Internal name: accountType
Data type: Single selection

Possible Values:

Internal name: checking

Internal name: savings
Account Number
Internal name: accountNumber
Data type: Single line text
Routing Number (US only)
Internal name: routingNumber
Data type: Single line text
Institution Number (CA only)
Internal name: institutionNumber
Data type: Single line text

Internal name:
Data type: bic
Internal name: iban
Data type: Single line text
Bank Sort Code
Internal name: bankSortCode
Data type: Single line text
3. Began with the the library script
Name: Plaid
Type: Library
Included libraries: none

Code: Select all

# Settings for the access token record type
auth.recordType = plaidAuth
auth.clientId = clientId
auth.clientSecret = clientSecret
auth.token = accessToken
auth.publicKey = publicKey

# Settings for Plaid
plaidEnv = plaidEnv
countryCodes = countryCodes
products = plaidProducts
node = index.js

# Settings for the Plaid Link record type
link.recordType = plaidLink
link.institutionId = institutionId
link.institutionName = institutionName
link.accountType = accountName
link.accountName = accountType
link.accountNumber = accountNumber
link.accountRouting = routingNumber
link.accountInstitutionNum = institutionNumber
link.accountBIC = bic
link.accountIBAN = iban
link.accountSortCode = sort_code

# Messages
error.invalidRequest = Invalid request
error.itemLoginRequired = Login required
error.itemNotSupported = Item not supported
error.mfaNotSupported = Multi-function authentication method used is not supported
error.noAccounts = There are no accounts associated with you at this institution
error.productNotReady = We are still pulling your account information from this financial institution. Please try again after a few seconds
Script code: This is where I'm struggling most and hoping I can get some help to move this forward

Code: Select all

import static*
import static*

import java.util.concurrent.CountDownLatch

import org.apache.commons.codec.binary.Base64
import org.cyclos.entities.banking.PaymentTransferType
import org.cyclos.entities.banking.SystemAccountType
import org.cyclos.entities.users.RecordCustomField
import org.cyclos.entities.users.SystemRecord
import org.cyclos.entities.users.SystemRecordType
import org.cyclos.entities.users.User
import org.cyclos.entities.users.UserRecord
import org.cyclos.entities.users.UserRecordType
import org.cyclos.impl.banking.PaymentServiceLocal
import org.cyclos.impl.system.ScriptHelper
import org.cyclos.impl.users.RecordServiceLocal
import org.cyclos.impl.utils.persistence.EntityManagerHandler
import org.cyclos.model.EntityNotFoundException
import org.cyclos.model.banking.accounts.SystemAccountOwner
import org.cyclos.model.banking.transactions.PaymentVO
import org.cyclos.model.banking.transactions.PerformPaymentDTO
import org.cyclos.model.banking.transfertypes.TransferTypeVO
import org.cyclos.model.users.records.RecordDataParams
import org.cyclos.model.users.records.UserRecordDTO
import org.cyclos.model.users.recordtypes.RecordTypeVO
import org.cyclos.model.users.users.UserLocatorVO
import org.cyclos.utils.ParameterStorage

 * Class used to store / retrieve the authentication information for Plaid
 * A system record type is used, with the following fields: client id (string),
 * client secret (string), and access token (string)
class PlaidAuth {
    String recordTypeName
    String clientIdName
    String clientSecretName
    String accessTokenName

    SystemRecordType recordType
    SystemRecord record
    Map<String, Object> wrapped

    public PlaidAuth(Object binding) {
        def params = binding.scriptParameters
        recordTypeName = params.'auth.recordType' ?: 'plaidAuth'
        clientIdName = params.'auth.clientId' ?: 'clientId'
        clientSecretName = params.'auth.clientSecret' ?: 'clientSecret'
        accessTokenName = params.'auth.accessToken' ?: 'accessToken'

        // Read the record type and the parameters for field internal names
        recordType = binding.entityManagerHandler
                .find(SystemRecordType, recordTypeName)

        // Should return the existing instance, of a single form type.
        // Otherwise it would be an error
        record = binding.recordService.newEntity(
                new RecordDataParams(recordType: new RecordTypeVO(id:
        if (!record.persistent) throw new IllegalStateException(
            "No instance of system record ${} was found")
        wrapped = binding.scriptHelper.wrap(record, recordType.fields)

    public String getClientId() {
    public String getClientSecret() {
    public String getAccessToken() {
    public void setClientId(String clientId) {
        wrapped[clientIdName] = clientId
    public void setClientSecret(String clientSecret) {
        wrapped[clientSecretName] = clientSecret
    public void setAccessToken(String accessToken) {
        wrapped[tokenName] = accessToken

// Instantiate the objects
PlaidAuth auth = new PlaidAuth(binding)
PlaidRecord record = new PlaidRecord(binding)
PlaidService plaid = new PlaidService(binding, auth, record)

 * Class used to store / retrieve Plaid items as user records in Cyclos
class PlaidRecord {
    String recordTypeName
    String itemIdName
    String accoutName
    String accoutTypeName
	String accoutNumberName
	String routingNumberName
	String institutionNumberName
	String bicName
	String ibanName
	String sortCodeName

    UserRecordType recordType
    Map<String, RecordCustomField> fields

    private EntityManagerHandler entityManagerHandler
    private RecordServiceLocal recordService
    private ScriptHelper scriptHelper

    public PlaidRecord(Object binding) {
        def params = binding.scriptParameters
        recordTypeName = params.'link.recordType' ?: 'plaidLink'
		institutionNameName = params.'link.institutionName' ?: 'institutionName'
        institutionIdName = params.'link.institutionId' ?: 'institutionId'
        itemIdName = params.'link.itemId' ?: 'itemId'

        entityManagerHandler = binding.entityManagerHandler
        recordService = binding.recordService
        scriptHelper = binding.scriptHelper
        recordType = binding.entityManagerHandler.find(UserRecordType, recordTypeName)
        fields = [:]
        recordType.fields.each {f -> fields[f.internalName] = f}

     * Creates a Plaid Link record, for the given user and JSON,
     * as returned from Plaid's create link REST method???

Re: Banking API Integration

Posted: Wed Jul 03, 2019 4:31 am
by shashank
is it sorted??

Re: Banking API Integration

Posted: Thu Jul 04, 2019 9:59 pm
by atitokor
Hi @shashank thanks. Not yet, I'm still waiting and hoping I can get some help with the scripting.