Class: SpreedlyCore::AuthorizeTransaction
- Inherits:
-
Transaction
- Object
- Base
- Transaction
- SpreedlyCore::AuthorizeTransaction
- Includes:
- HasIpAddress
- Defined in:
- lib/spreedly_core/transactions.rb
Instance Attribute Summary collapse
-
#payment_method ⇒ Object
readonly
Returns the value of attribute payment_method.
Attributes included from HasIpAddress
Attributes inherited from Transaction
#amount, #created_at, #currency_code, #gateway_token, #message, #on_test_gateway, #response, #succeeded, #token, #transaction_type, #updated_at
Instance Method Summary collapse
-
#capture(amount = nil, ip_address = nil) ⇒ Object
Capture the previously authorized payment.
-
#initialize(attrs = {}) ⇒ AuthorizeTransaction
constructor
A new instance of AuthorizeTransaction.
Methods inherited from Transaction
Methods inherited from Base
configure, gateway_token, login, verify_get, verify_options, verify_post, verify_put, verify_request
Constructor Details
#initialize(attrs = {}) ⇒ AuthorizeTransaction
Returns a new instance of AuthorizeTransaction.
83 84 85 86 87 |
# File 'lib/spreedly_core/transactions.rb', line 83 def initialize(attrs={}) @payment_method = PaymentMethod.new(attrs.delete("payment_method") || {}) @response = Response.new(attrs.delete("response") || {}) super(attrs) end |
Instance Attribute Details
#payment_method ⇒ Object (readonly)
Returns the value of attribute payment_method.
81 82 83 |
# File 'lib/spreedly_core/transactions.rb', line 81 def payment_method @payment_method end |
Instance Method Details
#capture(amount = nil, ip_address = nil) ⇒ Object
Capture the previously authorized payment. If the amount is nil, the captured amount will the amount from the original authorization. Some gateways support partial captures which can be done by specifiying an amount
93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/spreedly_core/transactions.rb', line 93 def capture(amount=nil, ip_address=nil) body = if amount.nil? {} else {:transaction => {:amount => amount, :ip => ip_address}} end self.class.verify_post("/transactions/#{token}/capture.xml", :body => body, :has_key => "transaction") do |response| CaptureTransaction.new(response.parsed_response["transaction"]) end end |