AbleCommerce Forums
»
AbleCommerce
»
AbleCommerce 9 Bug Reports
»
9.0.6 bug in CC month/year validation prevents valid card to be used
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);
}
|
1 user thanked Joe Payne2 for this useful post.
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 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
|
1 user thanked nadeem for this useful post.
|
|
|
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).
|
|
|
|
Rank: Advanced Member
Groups: Administrators, Developers, Registered, HelpDesk, Authorized User, Admin, System Joined: 10/11/2018(UTC) Posts: 110
Thanks: 19 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!
|
|
|
|
AbleCommerce Forums
»
AbleCommerce
»
AbleCommerce 9 Bug Reports
»
9.0.6 bug in CC month/year validation prevents valid card to be used
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.
Important Information:
The AbleCommerce Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
More Details
Close