Plaid Integration environment issues

Hi All,

I am trying to get the Plaid integration working but running into a few issues.

I have a fully enabled account for Transactions on Plaid which gives me access to the Sandbox, Development and Production environments and full integration for unlimited transactions on my bank accounts. I have all 3 api keys from the developer area on Plaid and can successfully create the Plaid integration on ERPNext in any of the 3 modes.

The issues however occur once you try to start syncing.

If you use the Sandbox environment, you are limited to the number of transactions you can sync which makes it useless for anything more than testing.

Both the Development and Production environments allow you to sync all your transactions but there seems to be an issue with the authentication process from the ERPNext side of things when trying to use either of those environments.

When using the development environment, it looks like ERPNext is still trying to authenticate with a sandbox token exchange -

Traceback with variables (most recent call last):
File “apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py”, line 74, in auth
self.client.Auth.get(self.access_token)
self = <erpnext.erpnext_integrations.doctype.plaid_settings.plaid_connector.PlaidConnector object at 0x7f5b4049cc70>
e = InvalidInputError('provided access token is for the wrong Plaid environment. expected “development”, got “sandbox”')
File “env/lib/python3.10/site-packages/plaid/api/auth.py”, line 23, in get

When using production, it looks like ERPNext is trying to use a different auth protocol / handshake to the development and sandbox processes. This auth process requires an account to have the “Auth” product enabled on the Plaid side which is not enabled / allowed on the entry level Plaid accounts and is only allowed on the $500+ / month services from Plaid. If ERPNext used the same authentication process as used in the Development / Sandbox environments for Production then this issue would be resolved (however there may still exist the issue as above where sandbox is sent instead of “production” in the handshake).

The response I had from Plaid regarding production access is as follows:

" Thanks for reaching out to Plaid Support!

I’ve taken a look in our logs for the identifier provided and it looks like this request failed on a auth/get request because your client_id is not enabled for Auth in Production. However, I’ve confirmed that this Item is healthy and should be returning transactions - Please try transactions/sync and let us know if you run into any issues!

Best,
Daniela
Plaid Support"

So, does anyone have any tips on how to actually get the Plaid integration working in anything but the sandbox environment so it can actually be used to sync transactions on a regular basis?

Thanks!

Ben

A quick update on this one -

I managed to get Plaid to enable the Auth module which fixes the issue with the production environment at least for the first synchronization but after that, it starts throwing the same error as when trying to use the development environment -

Traceback with variables (most recent call last):
  File "apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_connector.py", line 74, in auth
    self.client.Auth.get(self.access_token)
      self = <erpnext.erpnext_integrations.doctype.plaid_settings.plaid_connector.PlaidConnector object at 0x7fe335c8cc70>
      e = InvalidInputError('provided access token is for the wrong Plaid environment. expected "production", got "sandbox"')
  File "env/lib/python3.10/site-packages/plaid/api/auth.py", line 23, in get
    return self.client.post('/auth/get', {
      self = <plaid.api.auth.Auth object at 0x7fe334a1d750>
      access_token = ********
      _options = None
      account_ids = None
      options = {}
  File "env/lib/python3.10/site-packages/plaid/client.py", line 103, in post
    return self._post(path, post_data, is_json)
      self = <plaid.client.Client object at 0x7fe337d7acb0>
      path = '/auth/get'
      data = {'access_token': 'access-sandbox-3dda2f7d-c180-41e8-b56d-252daddd19fc', 'options': {}}
      is_json = True
      post_data = {'client_id': '<client id>', 'secret': '********', 'access_token': 'access-sandbox-3dda2f7d-c180-41e8-b56d-252daddd19fc', 'options': {}}

It looks like which ever environment you select, ERPNext ignores it and tries to use the sandbox environment in the auth token exchange.

Has anyone got this integration working and if so, how?