Class: Kaui::Transaction

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#next_retry_dateObject

Returns the value of attribute next_retry_date.



3
4
5
# File 'app/models/kaui/transaction.rb', line 3

def next_retry_date
  @next_retry_date
end

Class Method Details

.amount_to_money(transaction) ⇒ Object



37
38
39
# File 'app/models/kaui/transaction.rb', line 37

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

.build_from_raw_transaction(raw_transaction) ⇒ Object



5
6
7
8
9
10
11
# File 'app/models/kaui/transaction.rb', line 5

def self.build_from_raw_transaction(raw_transaction)
  result = Kaui::Transaction.new
  KillBillClient::Model::PaymentTransactionAttributes.instance_variable_get('@json_attributes').each do |attr|
    result.send("#{attr}=", raw_transaction.send(attr))
  end
  result
end

Instance Method Details

#amount_to_moneyObject



33
34
35
# File 'app/models/kaui/transaction.rb', line 33

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



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'app/models/kaui/transaction.rb', line 13

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