Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More details in reference when paying out with WISE #10630

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

xdamman
Copy link
Member

@xdamman xdamman commented Jan 14, 2025

Fixes opencollective/opencollective#7765

I'd recommend fetching the requirements first and applying the provided regex to verify the validity of the reference.
See https://docs.wise.com/api-docs/api-reference/transfer#transfer-requirements

In case of validation error, it's ok to fall back to just the expense.id.

Copy link
Member

@Betree Betree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend separating the two information (e.g. with a - character), otherwise it could mess up with collectives that have numbers in their names (e.g. "collective75" + Expense 42563 = "collective7542563").

For the rest, I'll let @kewitz give a proper review.

Comment on lines +246 to +260
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;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The substring should always be substring(0, maxLength - expense.id.toString().length). Looks like this was considered for some (GBP, EUR, USD) but not MXN

@kewitz
Copy link
Contributor

kewitz commented Jan 16, 2025

Xavier, I suggest addressing this in the frontend (PayExpenseModal), where we implemented the Wise reference validation and allow fiscal hosts to customize reference value.

I would happily implement this. Could you give a bit more information on the core problem this addresses? Or why isn't the expense id enough?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Default communication when paying with WISE
3 participants