module EasyCard
Constants
- CONST
- IV
- KEY
- SALT
- VERSION
Public Instance Methods
card_id(card_number)
click to toggle source
# File lib/easycard.rb, line 31 def card_id card_number remainder = card_number.size % 16 data = card_number + "\x06"*(16 - remainder) if remainder != 0 cipher = OpenSSL::Cipher.new('DES3') cipher.encrypt cipher.key = KEY cipher.iv = IV Base64.encode64(cipher.update(data)).chop! end
query(cart_number, from: Date.today-30, to: Date.today)
click to toggle source
# File lib/easycard.rb, line 18 def query cart_number, from: Date.today-30, to: Date.today query_hash = { cardID: card_id(cart_number), begin: from.strftime('%Y-%m-%d'), end: to.strftime('%Y-%m-%d'), verify: verify, ev: 1 } uri = URI('https://wallet.easycard.com.tw/EasyWallet/QueryManager/V3/GetTXNThinDataInfo') uri.query = URI.encode_www_form(query_hash) Response.new(Net::HTTP.get(uri)) end
verify(time = Time.now.localtime('+08:00'))
click to toggle source
# File lib/easycard.rb, line 41 def verify time = Time.now.localtime('+08:00') seed = time.month + time.day + time.hour Digest::MD5.hexdigest("#{seed * CONST}#{SALT}").upcase! end