A local-first personal finance app
use fallback linking parameters if initial GoCardless linking process fails (#5150)
Matt Fiddaman0a5acebeaffc
diff --git a/packages/sync-server/src/app-gocardless/services/gocardless-service.js b/packages/sync-server/src/app-gocardless/services/gocardless-service.jsindex 7b78b57d24..28d36f1e35 100644--- a/packages/sync-server/src/app-gocardless/services/gocardless-service.js+++ b/packages/sync-server/src/app-gocardless/services/gocardless-service.js@@ -317,24 +317,36 @@ export const goCardlessService = {institution.supported_features?.includes('account_selection') ?? false;let response;+ const body = {+ redirectUrl: host + '/gocardless/link',+ institutionId,+ referenceId: uuidv4(),+ accessValidForDays: institution.max_access_valid_for_days,+ maxHistoricalDays: BANKS_WITH_LIMITED_HISTORY.includes(institutionId)+ ? Number(institution.transaction_total_days) >= 90+ ? '89'+ : institution.transaction_total_days+ : institution.transaction_total_days,+ userLanguage: 'en',+ ssn: null,+ redirectImmediate: false,+ accountSelection,+ };try {- response = await client.initSession({- redirectUrl: host + '/gocardless/link',- institutionId,- referenceId: uuidv4(),- accessValidForDays: institution.max_access_valid_for_days,- maxHistoricalDays: BANKS_WITH_LIMITED_HISTORY.includes(institutionId)- ? Number(institution.transaction_total_days) >= 90- ? '89'- : institution.transaction_total_days- : institution.transaction_total_days,- userLanguage: 'en',- ssn: null,- redirectImmediate: false,- accountSelection,- });+ response = await client.initSession(body);} catch (error) {- handleGoCardlessError(error);+ try {+ console.log('Failed to link using:');+ console.log(body);+ console.log('Falling back to accessValidForDays = 90');++ response = await client.initSession({+ ...body,+ accessValidForDays: 90,+ });+ } catch (error) {+ handleGoCardlessError(error);+ }}const { link, id: requisitionId } = response;diff --git a/upcoming-release-notes/5150.md b/upcoming-release-notes/5150.mdnew file mode 100644index 0000000000..0f1f6594ad--- /dev/null+++ b/upcoming-release-notes/5150.md@@ -0,0 +1,6 @@+---+category: Enhancements+authors: [matt-fidd]+---++Use fallback linking parameters if initial GoCardless linking process fails