Class: Upay::Transaction
- Inherits:
-
Object
- Object
- Upay::Transaction
- Defined in:
- lib/upay/transaction.rb
Instance Method Summary collapse
- #capture_and_authorize ⇒ Object
- #cookie ⇒ Object
- #cookie=(cookie = nil) ⇒ Object
- #creditCardTokenId ⇒ Object
- #creditCardTokenId=(creditCardTokenId = nil) ⇒ Object
- #deviceSessionId ⇒ Object
- #deviceSessionId=(deviceSessionId = nil) ⇒ Object
-
#initialize(args = {}) ⇒ Transaction
constructor
A new instance of Transaction.
- #ipAddress ⇒ Object
- #ipAddress=(ipAddress = nil) ⇒ Object
- #order ⇒ Object
- #order=(order = nil) ⇒ Object
- #payer ⇒ Object
- #payer=(payer = nil) ⇒ Object
- #paymentCountry ⇒ Object
- #paymentCountry=(paymentCountry = nil) ⇒ Object
- #paymentMethod ⇒ Object
- #paymentMethod=(paymentMethod = nil) ⇒ Object
- #to_hash ⇒ Object
- #type ⇒ Object
- #type=(type = nil) ⇒ Object
- #userAgent ⇒ Object
- #userAgent=(userAgent = nil) ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(args = {}) ⇒ Transaction
Returns a new instance of Transaction.
3 4 5 6 7 |
# File 'lib/upay/transaction.rb', line 3 def initialize(args = {}) args.each do |k,v| instance_variable_set("@#{k}", v) end end |
Instance Method Details
#capture_and_authorize ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/upay/transaction.rb', line 39 def payload = {} payload["transaction"] = self.to_hash response = Payment.new.submit_transaction(payload)["response"] || {code: "ERROR", error: "something went terribly wrong"} if response["code"] == "SUCCESS" transaction_response_hash = response["transactionResponse"] || {} transaction_response = TransactionResponse.new(transaction_response_hash) else raise response.to_json.inspect end transaction_response end |
#cookie ⇒ Object
33 |
# File 'lib/upay/transaction.rb', line 33 def ; end |
#cookie=(cookie = nil) ⇒ Object
34 |
# File 'lib/upay/transaction.rb', line 34 def ( = nil) = end |
#creditCardTokenId ⇒ Object
15 |
# File 'lib/upay/transaction.rb', line 15 def creditCardTokenId; @creditCardTokenId end |
#creditCardTokenId=(creditCardTokenId = nil) ⇒ Object
16 |
# File 'lib/upay/transaction.rb', line 16 def creditCardTokenId=(creditCardTokenId = nil); @creditCardTokenId = creditCardTokenId; end |
#deviceSessionId ⇒ Object
27 |
# File 'lib/upay/transaction.rb', line 27 def deviceSessionId; @deviceSessionId end |
#deviceSessionId=(deviceSessionId = nil) ⇒ Object
28 |
# File 'lib/upay/transaction.rb', line 28 def deviceSessionId=(deviceSessionId = nil); @deviceSessionId = deviceSessionId; end |
#ipAddress ⇒ Object
30 |
# File 'lib/upay/transaction.rb', line 30 def ipAddress; @ipAddress; end |
#ipAddress=(ipAddress = nil) ⇒ Object
31 |
# File 'lib/upay/transaction.rb', line 31 def ipAddress=(ipAddress = nil) @ipAddress = ipAddress end |
#order ⇒ Object
9 |
# File 'lib/upay/transaction.rb', line 9 def order; @order end |
#order=(order = nil) ⇒ Object
10 |
# File 'lib/upay/transaction.rb', line 10 def order=(order = nil); @order = order; end |
#payer ⇒ Object
12 |
# File 'lib/upay/transaction.rb', line 12 def payer; @payer end |
#payer=(payer = nil) ⇒ Object
13 |
# File 'lib/upay/transaction.rb', line 13 def payer=(payer = nil); @payer = payer; end |
#paymentCountry ⇒ Object
24 |
# File 'lib/upay/transaction.rb', line 24 def paymentCountry; @paymentCountry end |
#paymentCountry=(paymentCountry = nil) ⇒ Object
25 |
# File 'lib/upay/transaction.rb', line 25 def paymentCountry=(paymentCountry = nil); @paymentCountry = paymentCountry; end |
#paymentMethod ⇒ Object
21 |
# File 'lib/upay/transaction.rb', line 21 def paymentMethod; @paymentMethod end |
#paymentMethod=(paymentMethod = nil) ⇒ Object
22 |
# File 'lib/upay/transaction.rb', line 22 def paymentMethod=(paymentMethod = nil); @paymentMethod = paymentMethod; end |
#to_hash ⇒ Object
58 59 60 61 62 63 |
# File 'lib/upay/transaction.rb', line 58 def to_hash transaction_hash = self.instance_variables.each_with_object({}) { |var,hash| hash[var.to_s.delete("@").to_sym] = self.instance_variable_get(var)} transaction_hash[:order] = self.order.to_hash if self.order transaction_hash[:payer] = self.payer.to_hash if self.payer transaction_hash end |
#type ⇒ Object
18 |
# File 'lib/upay/transaction.rb', line 18 def type; @type end |
#type=(type = nil) ⇒ Object
19 |
# File 'lib/upay/transaction.rb', line 19 def type=(type = nil); @type = type; end |
#userAgent ⇒ Object
36 |
# File 'lib/upay/transaction.rb', line 36 def userAgent; @userAgent end |
#userAgent=(userAgent = nil) ⇒ Object
37 |
# File 'lib/upay/transaction.rb', line 37 def userAgent=(userAgent = nil) @userAgent = userAgent; end |
#valid? ⇒ Boolean
53 54 55 56 |
# File 'lib/upay/transaction.rb', line 53 def valid? validator = TransactionValidator.new validator.valid?(self) end |