Class: SpreedlyCore::AuthorizeTransaction

Inherits:
Transaction show all
Includes:
HasIpAddress
Defined in:
lib/spreedly-core-ruby/transactions.rb

Instance Attribute Summary collapse

Attributes included from HasIpAddress

#ip

Attributes inherited from Transaction

#amount, #checkout_url, #created_at, #currency_code, #gateway_token, #message, #on_test_gateway, #response, #signed, #state, #succeeded, #token, #transaction_type, #updated_at

Instance Method Summary collapse

Methods inherited from Transaction

find, handles, #pending?, #valid_signature?, #verified!, #verified?

Methods inherited from Base

configure, environment_key, gateway_token, gateway_token=, verify_get, verify_options, verify_post, verify_put, verify_request

Constructor Details

#initialize(attrs = {}) ⇒ AuthorizeTransaction

Returns a new instance of AuthorizeTransaction.



113
114
115
116
117
# File 'lib/spreedly-core-ruby/transactions.rb', line 113

def initialize(attrs={})
  @payment_method = PaymentMethod.new(attrs.delete("payment_method") || {})
  @response = Response.new(attrs.delete("response") || {})
  super(attrs)
end

Instance Attribute Details

#payment_methodObject (readonly)

Returns the value of attribute payment_method.



111
112
113
# File 'lib/spreedly-core-ruby/transactions.rb', line 111

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



123
124
125
126
127
128
129
130
131
132
133
# File 'lib/spreedly-core-ruby/transactions.rb', line 123

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