Sha256: 82ce9eb2c711727dff614fff5ec23cf09f8178dd046eda9ba16a7e0ea16686e8

Contents?: true

Size: 1.47 KB

Versions: 20

Compression:

Stored size: 1.47 KB

Contents

class Kaui::Transaction < KillBillClient::Model::Transaction

  attr_accessor :next_retry_date

  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

  def create(account_id = nil, payment_method_id = nil, user = nil, reason = nil, comment = nil, options = {})
    if transaction_type == 'AUTHORIZE'
      auth(account_id, 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(account_id, payment_method_id, user, reason, comment, options)
    elsif transaction_type == 'PURCHASE'
      purchase(account_id, 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

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

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

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
kaui-2.1.0 app/models/kaui/transaction.rb
kaui-2.0.4 app/models/kaui/transaction.rb
kaui-2.0.3 app/models/kaui/transaction.rb
kaui-2.0.2 app/models/kaui/transaction.rb
kaui-2.0.1 app/models/kaui/transaction.rb
kaui-2.0.0 app/models/kaui/transaction.rb
kaui-1.4.1 app/models/kaui/transaction.rb
kaui-1.4.0 app/models/kaui/transaction.rb
kaui-1.3.0 app/models/kaui/transaction.rb
kaui-1.2.0 app/models/kaui/transaction.rb
kaui-1.1.0 app/models/kaui/transaction.rb
kaui-1.0.0 app/models/kaui/transaction.rb
kaui-0.16.2 app/models/kaui/transaction.rb
kaui-0.16.1 app/models/kaui/transaction.rb
kaui-0.16.0 app/models/kaui/transaction.rb
kaui-0.15.5 app/models/kaui/transaction.rb
kaui-0.15.4 app/models/kaui/transaction.rb
kaui-0.15.3 app/models/kaui/transaction.rb
kaui-0.15.2 app/models/kaui/transaction.rb
kaui-0.15.1 app/models/kaui/transaction.rb