Skip to content

Commit

Permalink
Fixes #7765
Browse files Browse the repository at this point in the history
  • Loading branch information
xdamman committed Jan 14, 2025
1 parent 17d7833 commit 7a42efd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion server/paymentProviders/transferwise/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
};
Expand Down

0 comments on commit 7a42efd

Please sign in to comment.