Module: SpreedlyCore::NullifiableTransaction

Included in:
CaptureTransaction, PurchaseTransaction
Defined in:
lib/spreedly_core/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



60
61
62
63
64
65
66
67
68
69
70
# File 'lib/spreedly_core/transactions.rb', line 60

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



50
51
52
53
54
55
56
# File 'lib/spreedly_core/transactions.rb', line 50

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