From 7a42efd8a10a6a16c1ba622a783caa5d880c745c Mon Sep 17 00:00:00 2001 From: Xavier Damman Date: Tue, 14 Jan 2025 17:58:50 +0100 Subject: [PATCH] Fixes #7765 --- server/paymentProviders/transferwise/index.ts | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/server/paymentProviders/transferwise/index.ts b/server/paymentProviders/transferwise/index.ts index d01611811f6..60422a593d5 100644 --- a/server/paymentProviders/transferwise/index.ts +++ b/server/paymentProviders/transferwise/index.ts @@ -242,13 +242,30 @@ async function createTransfer( throw new TransferwiseError(message, null, { quote }); } + const country = recipient.details.address?.country; + let reference = `${expense.collective.slug.toUpperCase().substring(0, 3)}${expense.id}`; // MAX 10 chars for the US + switch (country) { + case 'GBP': // max 18 chars + reference = `${expense.collective.slug.toUpperCase().substring(0, 10)}${expense.id}`; + break; + case 'EUR': // max 35 chars + reference = `${expense.collective.slug.substring(0, 25)}${expense.id}`; + break; + case 'USD': // max 10 chars + reference = `${expense.collective.slug.toUpperCase().substring(0, 3)}${expense.id}`; + break; + case 'MXN': // max 100 chars + reference = `${expense.collective.slug.substring(0, 100)}${expense.id}`; + break; + } + try { const transferOptions: transferwise.CreateTransfer = { accountId: recipient.id, quoteUuid: quote.id, customerTransactionId: uuid(), details: { - reference: `${expense.id}`, + reference, ...options?.details, }, };