Class: FatZebra::Models::Refund

Inherits:
Base
  • Object
show all
Defined in:
lib/fat_zebra/models/refund.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

attribute, #initialize, #inspect, #to_s

Constructor Details

This class inherits a constructor from FatZebra::Models::Base

Class Method Details

.create(transaction_id, amount, reference, optional = {}) ⇒ Refund

Refunds a transaction



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/fat_zebra/models/refund.rb', line 31

def create(transaction_id, amount, reference, optional = {})
  params = {
    :transaction_id => transaction_id,
    :amount => amount,
    :reference => reference
  }

  params.merge!(optional)

  response = FatZebra.gateway.make_request(:post, "refunds", params)
  Response.new(response, :refund)
end

Instance Method Details

#original_transactionObject

Returns the original transaction for this refund



10
11
12
# File 'lib/fat_zebra/models/refund.rb', line 10

def original_transaction
  @original_transaction ||= Purchase.find(self.original_transaction_id)
end

#successfulObject Also known as: successful?

Indicates if the refund was successful or not



17
18
19
# File 'lib/fat_zebra/models/refund.rb', line 17

def successful
  self.refunded == "Approved"
end