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

Difference between UTC and local time causes CreditCard to appear as not expired #1095

Closed
ardelio opened this issue Apr 1, 2014 · 2 comments

Comments

@ardelio
Copy link

ardelio commented Apr 1, 2014

We're currently experiencing an issue with credit card expiration that results from the difference between UTC time and current local time.

Referring to the code below, right now our local time is UTC+11. At 10:00:00AM (+1100), 1 April 2014, Time.now.utc returns 23:00:00 31 March 2014 UTC.

When the card expires in March 2014, expiration returns a time that is 23:59:59 31 March 2014 UTC.

A call to expired? thus returns false, however in local time, the card has expired (since we're now in April).

This seems like a bug that exists for the time difference between our local time and UTC time?

Our version: activemerchant (1.20.4)

Code

module ActiveMerchant
  module Billing
    class CreditCard
      class ExpiryDate #:nodoc:
...
        def expired? #:nodoc:
          Time.now.utc > expiration
        end

        def expiration #:nodoc:
          begin
            Time.utc(year, month, month_days, 23, 59, 59)
          rescue ArgumentError
            Time.at(0).utc
          end
        end
...
end
@bslobodin bslobodin self-assigned this Apr 1, 2014
@ntalbott
Copy link
Contributor

ntalbott commented May 7, 2014

@asceresini I'm not sure that it's within ActiveMerchant's scope to try to nail expired exactly; when a card actually expires is probably time zone dependent and somewhat up to the issuer regardless. What trouble did this cause you?

@ntalbott
Copy link
Contributor

I'm going to close this; it seems outside the scope of ActiveMerchant to nail the expiration time to the minute/hour.

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

3 participants