class Aurfy::Configure
Constants
- CREDIT_CARD_ORIGINAL_NAMES
Public Class Methods
keys()
click to toggle source
# File lib/aurfy/configure.rb, line 5 def self.keys [:cardnumber, :cardtype, :charset, :cv2, :expirydate, :orderamount, :ordercurrency, :orderdescription, :orderid, :ordertime, :merchantid, :signmethod, :trade_certificate, :transtype, :txnremark1, :txnremark2, :version, :website] end
new(values = {})
click to toggle source
# File lib/aurfy/configure.rb, line 11 def initialize(values = {}) Configure.keys.each do |key| next unless value = (values[key] || default_values[key]) instance_variable_set(:"@#{key}", value) end @cardtype = values[:card_type] || cardtype end
Public Instance Methods
params()
click to toggle source
# File lib/aurfy/configure.rb, line 20 def params sorted_variables.merge(signature: signature) end
signature_key()
click to toggle source
# File lib/aurfy/configure.rb, line 24 def signature_key sorted_variables.except(:signmethod).to_query + "&#{@trade_certificate}" end
sorted_variables()
click to toggle source
# File lib/aurfy/configure.rb, line 28 def sorted_variables variables = (instance_variables - [:@trade_certificate]).sort Hash[variables.map { |v| [v.to_s.sub("@", "").to_sym, instance_variable_get(v)] }] end
Private Instance Methods
cardtype()
click to toggle source
# File lib/aurfy/configure.rb, line 35 def cardtype card_information = credit_card_detector.detect(@cardnumber) CREDIT_CARD_ORIGINAL_NAMES[card_information.brand] end
credit_card_detector()
click to toggle source
# File lib/aurfy/configure.rb, line 40 def credit_card_detector CreditCardReader::Detector.new end
default_values()
click to toggle source
# File lib/aurfy/configure.rb, line 44 def default_values { charset: "UTF-8", ordercurrency: "USD", orderdescription: "", orderid: DateTime.now.strftime("%Y%m%d%H%M%S%N"), ordertime: DateTime.now.strftime("%Y%m%d%H%M%S"), signmethod: "MD5", transtype: "PURCHASE", txnremark1: "", txnremark2: "", version: "1.0", website: "" } end
signature()
click to toggle source
# File lib/aurfy/configure.rb, line 60 def signature Digest::MD5.hexdigest(signature_key) end