Class: Kaui::Payment

Inherits:
KillBillClient::Model::Payment
  • Object
show all
Includes:
PaymentState
Defined in:
app/models/kaui/payment.rb

Constant Summary collapse

TRANSACTION_STATUSES =
%w[SUCCESS PENDING PAYMENT_FAILURE PLUGIN_FAILURE UNKNOWN].freeze
REMAPPING_FIELDS =
{
  'auth_amount' => 'auth',
  'captured_amount' => 'capture',
  'purchased_amount' => 'purchase',
  'credited_amount' => 'credit',
  'refunded_amount' => 'refund'
}.freeze
ADVANCED_SEARCH_COLUMNS =
%w[id account_id payment_method_id external_key].freeze
ADVANCED_SEARCH_NAME_CHANGES =
[%w[ac_id account_id]].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Methods included from PaymentState

#amount_capturable, #amount_refundable, #capturable?, #chargebackable?, #fully_refunded?, #paid_amount_to_money, #refundable?, #returned_amount_to_money, #total_authed_amount_to_money, #voidable?

Instance Attribute Details

#payment_dateObject

Returns the value of attribute payment_date.



7
8
9
# File 'app/models/kaui/payment.rb', line 7

def payment_date
  @payment_date
end

#target_invoice_idObject

Returns the value of attribute target_invoice_id.



7
8
9
# File 'app/models/kaui/payment.rb', line 7

def target_invoice_id
  @target_invoice_id
end

Class Method Details

.build_from_raw_payment(raw_payment) ⇒ Object



20
21
22
23
24
25
26
# File 'app/models/kaui/payment.rb', line 20

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

.list_or_search(search_key = nil, offset = 0, limit = 10, options = {}) ⇒ Object



28
29
30
31
32
33
34
# File 'app/models/kaui/payment.rb', line 28

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