Nordigen/GoCardless fails for regional languages
dshoreman opened this issue · comments
Setup
- Version: 5.8.57
- Environment: Docker
Interface
- Flutter: []
- React: [x]
- Both: []
Checklist
- Can you replicate the issue on our v5 demo site https://demo.invoiceninja.com or https://react.invoicing.co/demo?
- Have you searched existing issues?
- Have you reported this to Slack/forum before posting?
- Have you inspected the logs in storage/logs/laravel.log for any errors?
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
- Add the
NORDIGEN_SECRET_*
vars to the .env and restart containers - Set your company/user language to a regional option, e.g. "English (United Kingdom)"
- Start bank flow with the "Connect Accounts" button
- 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!