Class: AdvancedBilling::PaymentType

Inherits:
Object
  • Object
show all
Defined in:
lib/advanced_billing/models/payment_type.rb

Overview

Payment Type.

Constant Summary collapse

PAYMENT_TYPE =
[
  # TODO: Write general description for CREDIT_CARD
  CREDIT_CARD = 'credit_card'.freeze,

  # TODO: Write general description for BANK_ACCOUNT
  BANK_ACCOUNT = 'bank_account'.freeze,

  # TODO: Write general description for PAYPAL_ACCOUNT
  PAYPAL_ACCOUNT = 'paypal_account'.freeze,

  # TODO: Write general description for APPLE_PAY
  APPLE_PAY = 'apple_pay'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = CREDIT_CARD) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/advanced_billing/models/payment_type.rb', line 29

def self.from_value(value, default_value = CREDIT_CARD)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'credit_card' then CREDIT_CARD
  when 'bank_account' then BANK_ACCOUNT
  when 'paypal_account' then PAYPAL_ACCOUNT
  when 'apple_pay' then APPLE_PAY
  else
    default_value
  end
end

.validate(value) ⇒ Object



23
24
25
26
27
# File 'lib/advanced_billing/models/payment_type.rb', line 23

def self.validate(value)
  return false if value.nil?

  PAYMENT_TYPE.include?(value)
end