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

Validation when creating a Payment Method on the My Account page #22

Open
solar984 opened this issue Oct 23, 2015 · 0 comments
Open

Validation when creating a Payment Method on the My Account page #22

solar984 opened this issue Oct 23, 2015 · 0 comments

Comments

@solar984
Copy link

This was reported by Ken Utting, theme developer at GORUCK:

There's a bug in the Core8 code, which prevents the Month/Year dropdowns from validating correctly when creating a Payment Method on the My Account page.

The method expirationDateInPast incorrectly returns false when validation fails, instead of a string. Also, the method incorrectly treats an empty Month selection as valid, because an empty Month selection can be represented by 0.

The method occurs in the file /scripts/modules/models-paymentmethods.js. Here is the correct code:

        expirationDateInPast: function (value, attr, computedState) {
        if (!this.selected) return undefined;
        var expMonth = this.get('expireMonth'),
            expYear = this.get('expireYear'),
            exp,
            thisMonth,
            isValid;

        // Fix bugs in Core8: provide better test for expMonth and return string instead of false
        if (isNaN(expMonth) || expMonth < 1 || isNaN(expYear))
                    return Hypr.getLabel('cardExpInvalid');

        exp = new Date(expYear, expMonth - 1, 1, 0, 0, 0, 0);
        thisMonth = new Date();
        thisMonth.setDate(1);
        thisMonth.setHours(0, 0, 0, 0);

        isValid = exp >= thisMonth;
        if (!isValid) return Hypr.getLabel('cardExpInvalid');
    },

You can reproduce the bug in our stock Core8 sandbox:
Open https://t13527-s18779.sandbox.mozu.com/myaccount
Log in with credentials [email protected] / fredflint1
Click on 'Fred' or click the link in step 1 to go to My Account
Click on Add New Card
Click on Save
Without the changes above, these steps will cause the Card Type, Card Number and Name on Card fields to display errors, but the Expires dropdowns have no error displayed. In fact, if valid information is placed in the other fields, Mozu will, in fact, save the card, with a month of 0 and no year.

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

No branches or pull requests

1 participant