Class: VivaPayAPI::Transaction
- Inherits:
-
Object
- Object
- VivaPayAPI::Transaction
- Includes:
- HTTParty
- Defined in:
- lib/vivapayapi.rb
Instance Method Summary collapse
- #amount ⇒ Object
- #capture(token) ⇒ Object
- #error_code ⇒ Object
- #error_text ⇒ Object
-
#initialize(username, password) ⇒ Transaction
constructor
A new instance of Transaction.
- #response ⇒ Object
- #status ⇒ Object
- #successful? ⇒ Boolean
- #transaction_id ⇒ Object
Constructor Details
#initialize(username, password) ⇒ Transaction
Returns a new instance of Transaction.
9 10 11 |
# File 'lib/vivapayapi.rb', line 9 def initialize(username, password) @auth = {:username => username , :password => password } end |
Instance Method Details
#amount ⇒ Object
37 38 39 40 41 42 |
# File 'lib/vivapayapi.rb', line 37 def amount unless @response.nil? @response["Amount"] end return nil end |
#capture(token) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/vivapayapi.rb', line 13 def capture(token) @response = self.class.post("/transactions", :basic_auth => @auth, :body => { :PaymentToken => token}.to_json, :headers => { 'Content-Type' => 'application/json' }, :debug_output => $stdout).parsed_response return @response end |
#error_code ⇒ Object
51 52 53 54 55 56 |
# File 'lib/vivapayapi.rb', line 51 def error_code unless @response.nil? return @response["ErrorCode"] end return nil end |
#error_text ⇒ Object
44 45 46 47 48 49 |
# File 'lib/vivapayapi.rb', line 44 def error_text unless @response.nil? return @response["ErrorText"] end return nil end |
#response ⇒ Object
58 59 60 |
# File 'lib/vivapayapi.rb', line 58 def response @response end |
#status ⇒ Object
30 31 32 33 34 35 |
# File 'lib/vivapayapi.rb', line 30 def status unless @response.nil? return @response["StatusId"] end return nil end |
#successful? ⇒ Boolean
62 63 64 65 66 67 |
# File 'lib/vivapayapi.rb', line 62 def successful? unless @response.nil? return (@response["ErrorCode"]==0 && @response["StatusId"] == "F") end return nil end |
#transaction_id ⇒ Object
23 24 25 26 27 28 |
# File 'lib/vivapayapi.rb', line 23 def transaction_id unless @response.nil? return @response["TransactionId"] end return nil end |