Class: PaymentType

Inherits:
ApplicationRecord show all
Defined in:
app/models/payment_type.rb

Overview

Schema Information

Table name: payment_types

id         :bigint           not null, primary key
name       :string(191)
created_at :datetime         not null
updated_at :datetime         not null

Indexes

index_payment_types_on_name  (name) UNIQUE

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from ApplicationRecord

sync_carrierwave_url

Class Method Details

.alipay_plusObject



58
59
60
# File 'app/models/payment_type.rb', line 58

def self.alipay_plus
  @alipay_plus ||= PaymentType.find_by!(name: 'alipay_plus')
end

.all_type_nameObject



21
22
23
# File 'app/models/payment_type.rb', line 21

def self.all_type_name
  PaymentType.all.map(&:name)
end

.credit_cardObject



46
47
48
# File 'app/models/payment_type.rb', line 46

def self.credit_card
  @credit_card ||= PaymentType.find_by!(name: 'credit_card')
end

.promptpayObject



42
43
44
# File 'app/models/payment_type.rb', line 42

def self.promptpay
  @promptpay ||= PaymentType.find_by!(name: 'promptpay')
end

.shopee_payObject



54
55
56
# File 'app/models/payment_type.rb', line 54

def self.shopee_pay
  @shopee_pay ||= PaymentType.find_by!(name: 'shopee_pay')
end

.true_walletObject



50
51
52
# File 'app/models/payment_type.rb', line 50

def self.true_wallet
  @true_wallet ||= PaymentType.find_by!(name: 'true_wallet')
end

.wechat_payObject



62
63
64
# File 'app/models/payment_type.rb', line 62

def self.wechat_pay
  @wechat_pay ||= PaymentType.find_by!(name: 'wechat_pay')
end

Instance Method Details

#humanize_nameObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/models/payment_type.rb', line 25

def humanize_name
  case name
  when 'promptpay'
    'PromptPay QR'
  when 'shopee_pay'
    'Shopee Pay'
  when 'credit_card'
    'Debit/ Credit Card'
  when 'true_wallet'
    'True Money Wallet'
  when 'alipay_plus'
    'Alipay+'
  when 'wechat_pay'
    'WeChat Pay'
  end
end