invoiceninja / invoiceninja

Invoices, Expenses and Tasks built with Laravel, Flutter and React

Home Page:https://invoiceninja.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Nordigen/GoCardless fails for regional languages

dshoreman opened this issue · comments

Setup

  • Version: 5.8.57
  • Environment: Docker

Interface

  • Flutter: []
  • React: [x]
  • Both: []

Checklist

Describe the bug

Setting up Nordigen/GoCardless bank integration fails for regional language variations.
The GoCardless API appears to only support 2-letter ISO 639 codes, but IN sends the "en_GB" variant.

Steps To Reproduce

  1. Add the NORDIGEN_SECRET_* vars to the .env and restart containers
  2. Set your company/user language to a regional option, e.g. "English (United Kingdom)"
  3. Start bank flow with the "Connect Accounts" button
  4. Select any bank

Expected Behavior

Expect to proceed to next step, instead it reports "unknown error" in the UI.

Additional context

Didn't check to see if there was a specific model method that gave the two letter code, but for now I'm working around it with this patch in both connect and confirm methods of NordigenController:

- $lang = $company->locale();
+ $lang = substr($company->locale(), 0, 2);

Logs

From invoiceninja.log after enabling EXPANDING_LOGGING:

[2024-05-30 19:26:52] production.INFO: {"user_language":{"summary":"Provided user_language is invalid or not supported","detail":"'en_GB' is an invalid or unsupported language"},"status_code":400}

@dshoreman did you want to pr this please?

Posted PR #9571 - I wasn't sure at first if it would work for all langs (hence issue vs PR) but after comparing db vs wikipedia, it should be fine for all the current languages.

The only edge case is really Norwegian, but it seems we got lucky with the code it's trimmed to.

Thanks!