Skip to content

[PAID] [$250] [Payment card / Subscription] limit input field to 16 digits in add-payment-card screen field for card number #44111

Closed

Description

@blimpich

If you haven’t already, check out our contributing guidelines for onboarding and email contributors@expensify.com to request to join our Slack channel!


Issue reported by: @blimpich

Action Performed:

Break down in numbered steps

  1. create a new account
  2. create a workspace on that account
  3. go to https://staging.new.expensify.com/settings/subscription/add-payment-card
  4. look at the card number field and type "abcdef01234567891234567"

Expected Result:

Describe what you think should've happened

Alphabet characters should not be allowed into the input field and the input field should be limited to 16 digits

Actual Result:

Describe what actually happened

"abcdef01234567891234567" shows up in the input field as typed

View all open jobs on GitHub

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0117d7a6e5f63d9c2e
  • Upwork Job ID: 1803868245221381580
  • Last Price Increase: 2024-06-20
  • Automatic offers:
    • fedirjh | Reviewer | 102858281
    • nkdengineer | Contributor | 102858284
Issue OwnerCurrent Issue Owner: @strepanier03

Activity

  1. converted this from a draft issue on Jun 20, 2024
  2. melvin-bot commented on Jun 20, 2024

    @melvin-bot

    Triggered auto assignment to @strepanier03 (Bug), see https://stackoverflow.com/c/expensify/questions/14418 for more details. Please add this bug to a GH project, as outlined in the SO.

  3. self-assigned this
    on Jun 20, 2024
  4. added
    ExternalAdded to denote the issue can be worked on by a contributor
    on Jun 20, 2024
  5. changed the title [-][Payment card / Subscription] limit input field to 16 digits in `add-payment-card` screen field for card number[/-] [+][$250] [Payment card / Subscription] limit input field to 16 digits in `add-payment-card` screen field for card number[/+] on Jun 20, 2024
  6. melvin-bot commented on Jun 20, 2024

    @melvin-bot
  7. added
    Help WantedApply this label when an issue is open to proposals by contributors
    on Jun 20, 2024
  8. melvin-bot commented on Jun 20, 2024

    @melvin-bot

    Triggered auto assignment to Contributor-plus team member for initial proposal review - @fedirjh (External)

  9. gijoe0295 commented on Jun 20, 2024

    @gijoe0295
    Contributor

    Proposal

    Please re-state the problem that we are trying to solve in this issue.

    Alphabet characters should not be allowed into the input field and the input field should be limited to 16 digits

    What is the root cause of that problem?

    This is a feature request.

    What changes do you think we should make in order to solve the problem?

    1. Create a cardNumber state and use it for the card number input's value
    value={cardNumber}
    1. Implement onValueChange for card number input where we remove all non-digit characters:
    onValueChange={(value) => {
        if (typeof value !== 'string') {
            return;
        }
        setCardNumber(value.replace(/\D/g, ''));
    }}
    1. Set maxLength={16}

    By this, when we pasted a string with non-digit characters, the input would only keep the digits and we couldn't type non-digit characters as well.

    What alternative solutions did you explore? (Optional)

    We can optionally format the card number to the space-separated form (i.e. 0123 4567 8910) using the above approach. Additionally, we should write a util function extractCardNumber to extract the plain digits without spaces so the submit handler could use the minified value.

    let formattedText = value.replace(/\D/g, '');
    if (formattedText.length > 0) {
        formattedText = formattedText.match(/.{1,4}/g)?.join(' ') || formattedText;
    }
    setCardNumber(formattedText);
  10. 42 remaining items

  11. melvin-bot commented on Jul 15, 2024

    @melvin-bot

    BugZero Checklist: The PR fixing this issue has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

    • [@fedirjh] The PR that introduced the bug has been identified. Link to the PR:
    • [@fedirjh] The offending PR has been commented on, pointing out the bug it caused and why, so the author and reviewers can learn from the mistake. Link to comment:
    • [@fedirjh] A discussion in #expensify-bugs has been started about whether any other steps should be taken (e.g. updating the PR review checklist) in order to catch this type of bug sooner. Link to discussion:
    • [@fedirjh] Determine if we should create a regression test for this bug.
    • [@fedirjh] If we decide to create a regression test for the bug, please propose the regression test steps to ensure the same bug will not reach production again.
    • [@strepanier03] Link the GH issue for creating/updating the regression test once above steps have been agreed upon:
  12. strepanier03 commented on Jul 17, 2024

    @strepanier03
    Contributor

    @nkdengineer - I've paid and closed the contract in Upwork.

    @fedirjh - I'll check tomorrow for the checklist and reg test steps above, then pay when that's completed.

    Thank you both!

  13. fedirjh commented on Jul 22, 2024

    @fedirjh
    Contributor

    BugZero Checklist:

    • Link to the PR: N/A, this is a new feature
    • Link to comment: N/A
    • Link to discussion: N/A
    • Determine if we should create a regression test for this bug: Yes

    Regression Test Proposal

    1. Create a new account
    2. Create a workspace on that account
    3. Go to /settings/subscription/add-payment-card
    4. Click at the card number field and type "abcdef01234567891234567"
    5. Verify that the input field should adhere to the following guidelines:
        - Only numeric characters should be allowed; alphabet characters are not permitted.
        - The input field should be restricted to a maximum of 16 digits.
        - Spacing should be added between every 4 digits within the input field.
    
    • Do we agree 👍 or 👎
  14. JmillsExpensify commented on Jul 22, 2024

    @JmillsExpensify
    Contributor

    @strepanier03 payment summary when you get a chance

  15. melvin-bot commented on Jul 23, 2024

    @melvin-bot

    @strepanier03, @blimpich, @fedirjh, @nkdengineer Huh... This is 4 days overdue. Who can take care of this?

  16. strepanier03 commented on Jul 23, 2024

    @strepanier03
    Contributor

    Payment Summary

    @JmillsExpensify - Request incoming.

  17. changed the title [-][HOLD for payment 2024-07-22] [HOLD for payment 2024-07-17] [$250] [Payment card / Subscription] limit input field to 16 digits in `add-payment-card` screen field for card number[/-] [+][PAID] [$250] [Payment card / Subscription] limit input field to 16 digits in `add-payment-card` screen field for card number[/+] on Jul 23, 2024
  18. JmillsExpensify commented on Jul 23, 2024

    @JmillsExpensify
    Contributor

    $250 approved for @fedirjh

  19. strepanier03 commented on Jul 24, 2024

    @strepanier03
    Contributor

    Looks great, thanks for confirming. Closing this now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Awaiting PaymentAuto-added when associated PR is deployed to productionBugSomething is broken. Auto assigns a BugZero manager.DailyKSv2EngineeringExternalAdded to denote the issue can be worked on by a contributor

Type

No type

Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions