Sha256: 85fcb9c023843c2566726c42e0a55a209e1b4f25382b3867739752155b545f8d

Contents?: true

Size: 935 Bytes

Versions: 5

Compression:

Stored size: 935 Bytes

Contents

class Kaui::Payment < KillBillClient::Model::Payment

  include Kaui::PaymentState

  attr_accessor :payment_date, :target_invoice_id

  SAMPLE_REASON_CODES = ['600 - Alt payment method',
                         '699 - OTHER']

  def self.build_from_raw_payment(raw_payment)
    result = Kaui::Payment.new
    KillBillClient::Model::PaymentAttributes.instance_variable_get('@json_attributes').each do |attr|
      result.send("#{attr}=", raw_payment.send(attr))
    end
    result
  end

  def self.list_or_search(search_key = nil, offset = 0, limit = 10, options = {})
    if search_key.present?
      find_in_batches_by_search_key(search_key, offset, limit, options)
    else
      find_in_batches(offset, limit, options)
    end
  end

  [:auth, :captured, :purchased, :refunded, :credited].each do |type|
    define_method "#{type}_amount_to_money" do
      Kaui::Base.to_money(send("#{type}_amount"), currency)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kaui-0.15.0 app/models/kaui/payment.rb
kaui-0.14.2 app/models/kaui/payment.rb
kaui-0.14.1 app/models/kaui/payment.rb
kaui-0.14.0 app/models/kaui/payment.rb
kaui-0.12.0 app/models/kaui/payment.rb