frappe / erpnext

Free and Open Source Enterprise Resource Planning (ERP)
https://erpnext.com
GNU General Public License v3.0
22.11k stars 7.4k forks source link

Multiple problems with Plaid Integration from Canada #19293

Open jd4ever opened 5 years ago

jd4ever commented 5 years ago

@chdecultot FYI there are multiple problems when trying to integrate with Plaid in Canada: 1) Canadian banks do not show up 2) Account selector does not show up and 3) python exception

1. Canadian banks do not show up I have been following the guidelines on Plaid integration and everything works until this step: https://erpnext.com/docs/user/manual/en/erpnext_integration/plaid_integration#bank-account-creation

Canadian banks do not show up in the list and do not show up when searching for them.

Plaid does have support for Canadian banks but require the following to access Canadian institutions, existing customers must include 'CA' within the countryCodes array during Link initialization https://blog.plaid.com/plaid-in-canada/

To work around this, I had to go into my Plaid account > Customize > Institution select and manually add my bank to the selections. Then I had to return to ERPnext to try again and select my Canadian bank on the main linking screen.

2. Account selector does not show up ERPnext fails silently if user does not chose an account during Plaid linking step. For the Account selector to show up, I had to again go into my Plaid account. So, Plaid account > customize > Select Account. Then change radio button to "enabled for multiple accounts"

3. Python exception After selecting account, I was taken back to ERPnext where I get to choose the organization to link it to. So far so good. But then as soon as I click continue, I get the following python error:

Traceback (most recent call last): File "/home/frappe/frappe-bench/apps/frappe/frappe/app.py", line 61, in application response = frappe.handler.handle() File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 21, in handle data = execute_cmd(cmd) File "/home/frappe/frappe-bench/apps/frappe/frappe/handler.py", line 56, in execute_cmd return frappe.call(method, **frappe.form_dict) File "/home/frappe/frappe-bench/apps/frappe/frappe/__init__.py", line 1032, in call return fn(*args, **newargs) File "/home/frappe/frappe-bench/apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py", line 59, in add_bank_accounts for account in response["accounts"]: TypeError: string indices must be integers

racitup commented 4 years ago

I can confirm I get the same error as 3 when using Plaid sandbox in the UK with version: ERPNext: v12.1.6 (version-12) Frappe Framework: v12.0.16 (version-12) People should also realise that with this version, the plaid_client_id, plaid_public_key, plaid_env & plaid_secret are now available as Plaid Settings within the UI rather than the site_config.json (though there are issues with the UI as I hope to raise as a separate issue: #20242)

racitup commented 4 years ago

Fix to 3 merged in #20335

racitup commented 4 years ago

For item 2 ERPNext appears to simply add all accounts from the Plaid response, so for example if there is a savings and current account, both will be added by default. I guess it could be argued this is a feature and as you point out you can modify the Plaid interface to change the behaviour, or simply delete the accounts you don't want from ERPNext after import.

duzluk commented 4 years ago

Fix to 3 merged in #20335

Is this fixed

racitup commented 4 years ago

Fix to 3 merged in #20335

Is this fixed

It's merged into the develop branch. No idea when it will make it into the version-12 release

duzluk commented 4 years ago

20335 worked for me. But now I'm getting this error now: Traceback (most recent call last): File "/home/bten/bten-bench/apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py", line 86, in add_bank_accounts "mask": account["mask"] or "", KeyError: 'mask'

racitup commented 4 years ago

I've been fixing bugs in Plaid recently on v12 but haven't seen that error. Which version are you on? See #20380

duzluk commented 4 years ago

ERPNext: v12.3.1 (version-12) Frappe Framework: v12.1.0 (version-12)

racitup commented 4 years ago

I've used that version and didn't see that problem.. Are you connecting to plaid in sandbox, developer or production mode? Also which country?

duzluk commented 4 years ago

I'm using developer mode. USA. (Bank of America)

racitup commented 4 years ago

I'm using developer mode. USA. (Bank of America)

Are you a developer? Could you try changing line 67 (just before the for loop) of apps/erpnext/erpnext/erpnext_integrations/doctype/plaid_settings/plaid_settings.py to: frappe.logger().debug("{}".format(response)) Then try adding your bank again. If you look in frappe.log inside the bench/logs folder you should see the Plaid response output. Paste it here once you have appropriately sanitised it?