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

Credit Card Expiry Date Format #1781

Closed
amjad opened this issue Jun 14, 2017 · 12 comments
Closed

Credit Card Expiry Date Format #1781

amjad opened this issue Jun 14, 2017 · 12 comments
Assignees
Milestone

Comments

@amjad
Copy link

amjad commented Jun 14, 2017

Some gateways accept the expiry date as MM/YY only. But the form takes MM/YYYY too and this is causing transactions to fail because of if people enter the full year our gateway send back an error of invalid expiry date.

How can we override this and allow only MM/YY as input?

@ravinderk
Copy link
Collaborator

@DevinWalker @mathetos I would like to suggest dropdown for expiry date instead of input field which has js for expiry date formatting.
For ref: http://usabilityetc.com/2015/03/credit-card-expiration-date-user-interface/

@amjad Can you handle this case with PHP code. I think it is good to take expiry date in MM/YYYY format from donor.

@amjad
Copy link
Author

amjad commented Jun 15, 2017

Where can this be overridden in PHP?

Dropdown would be nice to avoid errors. Correct me if I'm wrong, but isn't MM/YY format the standard? I haven't seen any cards with MM/YYYY on them, at least not in US.

@mathetos
Copy link
Member

Example from Amazon.com, uses a dropdown and YYYY
image

Stripe checkout is a number field with YY
https://stripe.com/checkout
image

So it seems there isn't a clear standard, but obviously we don't want cards failing. Seems we need to implement some sort of validation that is determined by the payment gateway itself to display the year either with 2 digits or 4.

With that in mind, I can see that it makes sense to do it with a Dropdown because it will be a consistent user experience but you can format the year programmatically... I just personally think it takes LONGER to enter the year with a dropdown than by typing, so my vote would be a number field instead. I'm sure we can still do YY validation even with a number field.

Just my two cents.

@ravinderk
Copy link
Collaborator

ravinderk commented Jun 15, 2017

@amjad before sending data to payment gateway server, you can fix expiry date according to your format.

For ref: https://github.com/WordImpress/give-americloud-payments/blob/master/includes/give-americloud-gateway.php#L55

@amjad
Copy link
Author

amjad commented Jun 15, 2017

@ravinderk is there a way to limit input to MM/YY rather than formatting before sending to gateway?

@kevinwhoffman
Copy link
Contributor

kevinwhoffman commented Jun 15, 2017

Dropdowns should be the UI of last resort, especially on mobile. They introduce unnecessary complexity in this case. See https://www.lukew.com/ff/entry.asp?1950.

A text field with an input mask is the better UX, and we can still do client-side and server-side validation to ensure the data is in the right format.

As for what the format should be, I believe it should be MM/YY since that is the format reflected on most credit and debit cards (I don't know of a card that displays the year in four digits). The date in MM/YY format is also what users are looking at when they enter their information, so it makes sense to accept that format. On the Give demo, the placeholder value is actually MM/YY but the field accepts MM/YYYY. That's not right. (Edit: It actually accepts both formats like Stripe)

Recommended Next Steps

If we know the MM/YYYY format is causing errors and goes against the expected format on the card, then we should consider changing the date field to only accept MM/YY. We should check to ensure that all of our gateways accept this format, but even if they do not, it should be trivial to convert the two-digit year to a four-digit year in the gateway add-on.

@ravinderk
Copy link
Collaborator

@amjad currently you can achieve that with custom js only.

@kevinwhoffman
Copy link
Contributor

kevinwhoffman commented Jun 15, 2017

I just tried the Stripe demo (click Donate to Watsi) and although the placeholder says MM/YY it accepts either MM/YY or MM/YYYY. This matches the behavior in Give.

In light of that, I'm changing my recommendation... We should leave the behavior as is and if a certain gateway requires a special format, that formatting can be handled in the add-on.

@ravinderk
Copy link
Collaborator

@kevinwhoffman I want to suggest adding some js validation before submitting donation form. I reviewed code and we are adding error/valid class to the expiry date. We can submit donation form even there is error in expiry date (10/222) and we will get an error after submitting donation form.

phxiexkjlh

we can address this issue within 2.0 with parsley js

@kevinwhoffman
Copy link
Contributor

@ravinderk If we can improve JS validation, I am all for it. I just don't think it requires a dropdown to do so.

@amjad
Copy link
Author

amjad commented Jun 16, 2017

@ravinderk I have fixed this issue for our gateway. Now when user enters 17 or 2017 as year it will send to payment server as 17. Thanks everyone!

@ravinderk
Copy link
Collaborator

@am Glad, you fixed it.

We will close this soon, need to add some fix to make it future proof.

@DevinWalker DevinWalker added this to the 1.8.9 milestone Jun 19, 2017
ravinderk added a commit to ravinderk/Give that referenced this issue Jun 21, 2017
@ravinderk ravinderk mentioned this issue Jun 21, 2017
3 tasks
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

6 participants