Class: Aurfy::Configure
- Inherits:
-
Object
- Object
- Aurfy::Configure
- Defined in:
- lib/aurfy/configure.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Configure
constructor
A new instance of Configure.
- #options=(options = {}) ⇒ Object
- #params ⇒ Object
- #signature_key ⇒ Object
- #sorted_variables ⇒ Object
Constructor Details
#initialize ⇒ Configure
Returns a new instance of Configure.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/aurfy/configure.rb', line 9 def initialize @cardtype = "UP" @charset = "UTF-8" @ordertime = DateTime.now.strftime("%Y%m%d%H%M%S") @orderid = DateTime.now.strftime("%Y%m%d%H%M%S%N") @ordercurrency = "USD" @orderdescription = "" @signmethod = "MD5" @transtype = "PURCHASE" @txnremark1 = "" @txnremark2 = "" @version = "1.0" @website = "" end |
Class Method Details
.keys ⇒ Object
3 4 5 6 7 |
# File 'lib/aurfy/configure.rb', line 3 def self.keys [:merchantid, :orderid, :ordertime, :ordercurrency, :orderamount, :orderdescription, :txnremark1, :txnremark2, :charset, :clientip, :version, :transtype, :website, :cardtype, :cardnumber, :cv2, :expirydate, :signmethod, :trade_certificate] end |
Instance Method Details
#options=(options = {}) ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/aurfy/configure.rb', line 28 def ( = {}) .each_pair do |key, value| next unless Configure.keys.include? key instance_variable_set(:"@#{key}", value) end end |
#params ⇒ Object
24 25 26 |
# File 'lib/aurfy/configure.rb', line 24 def params sorted_variables.merge({ signature: signature }) end |
#signature_key ⇒ Object
42 43 44 |
# File 'lib/aurfy/configure.rb', line 42 def signature_key sorted_variables.delete_if { |k, _| k == :signmethod }.map {|p| "#{p.first}=#{p.last}" }.join("&") + "&#{@trade_certificate}" end |
#sorted_variables ⇒ Object
36 37 38 39 40 |
# File 'lib/aurfy/configure.rb', line 36 def sorted_variables instance_variables.map { |v| [v.to_s.sub("@", "").to_sym, instance_variable_get(v)] }.delete_if do |k, _| k == :trade_certificate end.sort.to_h end |