Class: Kaui::Transaction

Inherits:
KillBillClient::Model::Transaction
  • Object
show all
Defined in:
app/models/kaui/transaction.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.amount_to_money(transaction) ⇒ Object



27
28
29
# File 'app/models/kaui/transaction.rb', line 27

def self.amount_to_money(transaction)
  self.new(:amount => transaction.amount, :currency => transaction.currency).amount_to_money
end

Instance Method Details

#amount_to_moneyObject



23
24
25
# File 'app/models/kaui/transaction.rb', line 23

def amount_to_money
  Kaui::Base.to_money(amount, currency)
end

#create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {}) ⇒ Object



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/kaui/transaction.rb', line 3

def create( = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
  if transaction_type == 'AUTHORIZE'
    auth(, payment_method_id, user, reason, comment, options)
  elsif transaction_type == 'CAPTURE'
    capture(user, reason, comment, options)
  elsif transaction_type == 'CHARGEBACK'
    chargeback(user, reason, comment, options)
  elsif transaction_type == 'CREDIT'
    credit(, payment_method_id, user, reason, comment, options)
  elsif transaction_type == 'PURCHASE'
    purchase(, payment_method_id, user, reason, comment, options)
  elsif transaction_type == 'REFUND'
    refund(user, reason, comment, options)
  elsif transaction_type == 'VOID'
    void(user, reason, comment, options)
  else
    raise ArgumentError.new("Unknown transaction type #{transaction_type}")
  end
end