Sha256: 098e1b3fb67f03208da6092790c253493e48093617d751f104b5b74e63f9774e

Contents?: true

Size: 1020 Bytes

Versions: 5

Compression:

Stored size: 1020 Bytes

Contents

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

  include Kaui::PaymentState

  attr_accessor :payment_date, :target_invoice_id

  TRANSACTION_STATUSES = %w(SUCCESS PENDING PAYMENT_FAILURE PLUGIN_FAILURE UNKNOWN)

  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.5 app/models/kaui/payment.rb
kaui-0.15.4 app/models/kaui/payment.rb
kaui-0.15.3 app/models/kaui/payment.rb
kaui-0.15.2 app/models/kaui/payment.rb
kaui-0.15.1 app/models/kaui/payment.rb