Module: SpreedlyCore::NullifiableTransaction

Included in:
CaptureTransaction, PurchaseTransaction
Defined in:
lib/spreedly-core-ruby/transactions.rb

Instance Method Summary collapse

Instance Method Details

#credit(amount = nil, ip_address = nil) ⇒ Object

Credit amount. If amount is nil, then credit the entire previous purchase or captured amount



90
91
92
93
94
95
96
97
98
99
100
# File 'lib/spreedly-core-ruby/transactions.rb', line 90

def credit(amount=nil, ip_address=nil)
  body = if amount.nil?
           {:ip => ip_address}
         else
           {:transaction => {:amount => amount, :ip => ip_address}}
         end
  self.class.verify_post("/transactions/#{token}/credit.xml",
                         :body => body, :has_key => "transaction") do |response|
    CreditTransaction.new(response.parsed_response["transaction"])
  end
end

#void(ip_address = nil) ⇒ Object

Void is used to cancel out authorizations and, with some gateways, to cancel actual payment transactions within the first 24 hours



80
81
82
83
84
85
86
# File 'lib/spreedly-core-ruby/transactions.rb', line 80

def void(ip_address=nil)
  body = {:transaction => {:ip => ip_address}}
  self.class.verify_post("/transactions/#{token}/void.xml",
                         :body => body, :has_key => "transaction") do |response|
    VoidedTransaction.new(response.parsed_response["transaction"])
  end
end