logo
Welcome to our new AbleCommerce forums. As a guest, you may view the information here. To post to this forum, you must have a registered account with us, either as a new user evaluating AbleCommerce or an existing user of the application. For all questions related to the older version of Gold and earlier, please go to AbleCommerce Gold forum. Please use your AbleCommerce username and password to Login. New Registrations are disabled.

Notification

Icon
Error

Options
Go to last post Go to first unread
Joe Payne2  
#1 Posted : Thursday, July 14, 2022 3:17:08 PM(UTC)
Joe Payne2

Rank: Advanced Member

Groups: HelpDesk, Developers
Joined: 11/9/2018(UTC)
Posts: 564

Thanks: 122 times
Was thanked: 26 time(s) in 25 post(s)
The code used to validate the month/year of a credit card for processing a charge is not correct.

The expireDate value is being computed as the 1st day of the month. A credit card is valid until the last day of the expiration month.

This prevents using a valid credit card in the month the card expires.

Code:

        public ActionResult ValidateCCExpirationDate(int? ExpirationMonth, int? ExpirationYear)
        {
            if (!ExpirationMonth.HasValue || !ExpirationYear.HasValue)
                return Json(false, JsonRequestBehavior.AllowGet);

            // must be a future date
            var expiryDate = Misc.GetStartOfDate(new DateTime(ExpirationYear.Value, ExpirationMonth.Value, 1));

            return Json(expiryDate > DateTime.Now, JsonRequestBehavior.AllowGet);
        }
thanks 1 user thanked Joe Payne2 for this useful post.
nadeem on 7/15/2022(UTC)

Wanna join the discussion?! Login to your AbleCommerce Forums forum account. New Registrations are disabled.

nadeem  
#2 Posted : Friday, July 15, 2022 8:34:10 AM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 times
Was thanked: 18 time(s) in 18 post(s)
Hi Joe,

I think this makes sense to have the end of the month date as the expiration for a card. I have logged an issue to investigate for a future release. Thanks for pointing that out.

For now, you can apply a workaround something like this:

Update the following line of code inside ValidateCCExpirationDate function

Code:
var expiryDate = Misc.GetStartOfDate(new DateTime(ExpirationYear.Value, ExpirationMonth.Value, 1));


to

Code:
int day = DateTime.DaysInMonth(ExpirationYear.Value, ExpirationMonth.Value);
var expiryDate = Misc.GetEndOfDate(new DateTime(ExpirationYear.Value, ExpirationMonth.Value, day));

Edited by user Friday, July 15, 2022 9:46:09 AM(UTC)  | Reason: Not specified

thanks 1 user thanked nadeem for this useful post.
Joe Payne2 on 7/15/2022(UTC)
Jay  
#3 Posted : Friday, July 15, 2022 9:30:39 AM(UTC)
Jay

Rank: Member

Groups: Authorized User, Developers
Joined: 11/12/2018(UTC)
Posts: 25

Thanks: 1 times
Was thanked: 4 time(s) in 3 post(s)
Wouldn't that still cause validation to fail on the last day of them month? Seems like the time should be the end of the day, not the start of the day (or perhaps the start of the next day).
nadeem  
#4 Posted : Friday, July 15, 2022 9:48:23 AM(UTC)
nadeem

Rank: Advanced Member

Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System
Joined: 10/11/2018(UTC)
Posts: 109

Thanks: 17 times
Was thanked: 18 time(s) in 18 post(s)
Nice catch! Yes, this will expire the card on the start of the last day. I just updated the code above to use the GetEndOfDate instead. Thanks again for correction!
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.