-
Notifications
You must be signed in to change notification settings - Fork 3k
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
[HOLD for payment 2024-12-16] [$125] Error message displayed when adding a UK zip code to a GBP payment card #52642
Comments
Triggered auto assignment to @sakluger ( |
ProposalPlease re-state the problem that we are trying to solve in this issue.Adding a UK zip code to a GBP payment card errors out incorrectly What is the root cause of that problem?We only check valid zip code and not check valid us post code App/src/components/AddPaymentCard/PaymentCardForm.tsx Lines 168 to 170 in 1b9e302
What changes do you think we should make in order to solve the problem?
Notes: we should add What alternative solutions did you explore? (Optional)Simply we only need to update |
This seems like a pretty easy change. I'm going to set the initial price at $125. If this needs to be done for several countries, and each one requires specific treatment, then we can consider a higher price, but it doesn't seem like that's necessary for now. |
Job added to Upwork: https://www.upwork.com/jobs/~021857542773027117579 |
Triggered auto assignment to Contributor-plus team member for initial proposal review - @getusha ( |
Upwork job price has been updated to $125 |
Edited by proposal-police: This proposal was edited at 2024-11-18 19:58:48 UTC. ProposalPlease re-state the problem that we are trying to solve in this issueError message displayed when adding a UK zip code to a GBP payment card. What is the root cause of that problem?The current App/src/components/AddPaymentCard/PaymentCardForm.tsx Lines 168 to 170 in 99bf554
What changes do you think we should make in order to solve the problem?Adjust the validate logic similarly to what we do in Address / AddressForm which is Zip Code validation based on the selected country, in our case for a more comprehensive solution we'll validate Zip Code based on selected Currency. To do this we will add / adjust the following:
/**
* Get the country code for a certain currency(ISO 4217) Code
*/
function getCurrencyCountryCodes(currencyCode: keyof typeof CONST.CURRENCY): Array<keyof typeof CONST.ALL_COUNTRIES> {
const currencyCountryMap: Record<keyof typeof CONST.CURRENCY, Array<keyof typeof CONST.ALL_COUNTRIES>> = {
[CONST.CURRENCY.USD]: ['US'],
[CONST.CURRENCY.AUD]: ['AU'],
[CONST.CURRENCY.CAD]: ['CA'],
[CONST.CURRENCY.GBP]: ['GB'],
[CONST.CURRENCY.NZD]: ['NZ'],
[CONST.CURRENCY.EUR]: ['AT', 'BE', 'CY', 'EE', 'FI', 'FR', 'DE', 'GR', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PT', 'SK', 'SI', 'ES'],
};
return currencyCountryMap[currencyCode] ?? [];
}
// Use provided currency or default to USD
const currency = data?.currency ?? CONST.PAYMENT_CARD_CURRENCY.USD;
// Get countries associated with the currency
const countries = CurrencyUtils.getCurrencyCountryCodes(currency);
// Check if the addressZipCode matches any country-specific regex
if (values.addressZipCode) {
const zipCode = values.addressZipCode.trim();
const isValidZip = countries.some((countryCode) => {
const regexDetails = CONST.COUNTRY_ZIP_REGEX_DATA[countryCode];
// Optionally: check for empty string after trim
if (!zipCode) {
return false;
}
return 'regex' in regexDetails && regexDetails.regex.test(zipCode);
});
if (!isValidZip) {
errors.addressZipCode = translate(label.error.addressZipCode);
}
} this will ensure that the Zip Code is validated based on the currency selected in the Add payment card, defaulting to USD just like the Currency field. Here's a test branch: ikevin127-cardZipCodeValidation for testing convenience or the diff if preferred. Alternative solution 1Map over all Alternative solution 2Remove any specific Zip Code validation, allowing any input as long as the field is not empty. This one would be the most performant (since this seems to be a very important criteria 🙂). Alternative solution 3Use Result video (before / after)MacOS: Chrome
|
@sakluger In the proposed solution I made sure to include logic for each specific currency / country and also for the I'd say that justifies the base $250 bounty for this issue in case the proposed solution will be the one selected. Thank you! |
@ikevin127 that sounds fair to me! If your solution is selected, then I will increase the price to $250. |
@ikevin127 @daledah we already have |
@getusha Are you sure you read my proposal ? Asking because I'm confused by your note since I did use |
mb, i overlooked that. reviewing your solution |
@ikevin127 after a second look i am not sure if mapping currencies to countries is the right idea. as there could be for example, someone from |
ProposalPlease re-state the problem that we are trying to solve in this issue.Error message displayed when adding a UK zip code to a GBP payment card What is the root cause of that problem?We only check valid US zip code and not check valid UK zip code App/src/components/AddPaymentCard/PaymentCardForm.tsx Lines 168 to 170 in 8e1b0fd
What changes do you think we should make in order to solve the problem?we must handle UK zip code when the GBP currency is selected
What alternative solutions did you explore? (Optional) |
📣 @YahyaDalbah! 📣
|
@getusha If by generic regex you mean simply allowing any postcode then we might as well remove any validation as we're not interested in actually validating based on each country's regex. The reason why I propose validating based on currency is because especially in the US, if you don't input the Zip Code matching the card - the bank will reject authorization / payment. Updated proposalAdded alternative solution where we map over all Hopefully this will satisfy, otherwise I need more specificity on what exactly you're expecting in terms of solution here. |
Contributor details |
✅ Contributor details stored successfully. Thank you for contributing to Expensify! |
We are selecting a currency not a country, i don't see how that's relevant.
Having a
It might cause performance implications, which could make the solution not ideal. |
@getusha You are not making any sense honestly, first you say:
Then when I suggested 2 different solutions using I don't understand what are your expectations in this case, can you clarify ? Also please test the solutions and come back with solid proof that the solution does introduce performance issues, because "might" means nothing. Let me know if you have the capacity to do that and want to review this issue properly, otherwise I will propose re-assigning another reviewer. Thanks! |
PR #53178 is ready for review! 🚀 |
♻️ Status update: PR has been open and ready for review 2 days ago, awaiting @getusha's review. |
♻️ Status update: PR has been open and ready for review for 5 days, still awaiting @getusha's review. |
Just as a bit of a follow-up here if that PR is almost done and dusted, but I think we should change the label name to |
@trjExpensify Sure, will change the label before the PR gets merged - linking to your comment for the reason. ✅ Done |
Excellent! |
Updated postcode input label to match the label found in the form on Settings > Profile > Private > Address , as requested in Expensify#52642 (comment).
|
The solution for this issue has been 🚀 deployed to production 🚀 in version 9.0.72-1 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue: If no regressions arise, payment will be issued on 2024-12-16. 🎊 For reference, here are some details about the assignees on this issue:
|
@ikevin127 / @getusha @sakluger @ikevin127 / @getusha The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed. Please copy/paste the BugZero Checklist from here into a new comment on this GH and complete it. If you have the K2 extension, you can simply click: [this button] |
BugZero Checklist:
Bug classificationSource of bug:
Where bug was reported:
Who reported the bug:
Regression Test Proposal
Do we agree 👍 or 👎. |
@sakluger for visibility |
Sorry for the delayed payment, I was out sick yesterday. Also, thank you @ikevin127 for completing the BZ checklist. That's usually the responsibility of the Contributor+ assignee, but I appreciate you doing that here. |
Summarizing payment on this issue: Contributor: @ikevin127 $125, paid via Upwork |
$125 approved for @getusha |
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Version Number: 9.0.63-1
Reproducible in staging?: Y
Reproducible in production?: Y
If this was caught on HybridApp, is this reproducible on New Expensify Standalone?:
If this was caught during regression testing, add the test name, ID and link from TestRail:
Email or phone of affected tester (no customers):
Logs: https://stackoverflow.com/c/expensify/questions/4856
Expensify/Expensify Issue URL:
Issue reported by: @muttmuure
Slack conversation (hyperlinked to channel name): ts_external_expensify_bugs
Action Performed:
Expected Result:
A UK post code is accepted
Actual Result:
The Zip Code field shows an error.
Workaround:
Unknown
Platforms:
Which of our officially supported platforms is this issue occurring on?
Screenshots/Videos
Add any screenshot/video evidence
View all open jobs on GitHub
Upwork Automation - Do Not Edit
Issue Owner
Current Issue Owner: @saklugerThe text was updated successfully, but these errors were encountered: