Module: SpreeBankTransfer::PaymentDecorator

Defined in:
app/models/spree_bank_transfer/payment_decorator.rb

Constant Summary collapse

BANK_ATTRIBUTES =

このモジュールは Spree::Payment に prepend されるため、これらの定数は ancestors 経由で Spree::Payment::BANK_ATTRIBUTES / ::RECEIPT_VALID_TYPES として参照できる (payments_controller / payment/bank_updater / _bank_transfer_form.html.erb が参照している)。

[ :deposited_on, :bank_name, :account_no, :transaction_reference_no, :receipt ]
RECEIPT_VALID_TYPES =
%w[image/png image/jpeg image/jpg].freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prepended(base) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/models/spree_bank_transfer/payment_decorator.rb', line 11

def self.prepended(base)
  base.attr_accessor :validate_bank_details

  base.has_one_attached :receipt

  base.validate :validate_receipt_type, if: :validate_bank_details
  base.validates :bank_name, :deposited_on, :receipt, presence: true, if: :validate_bank_details

  base.scope :from_bank_transfer, lambda {
    joins(:payment_method).where(spree_payment_methods: { type: 'Spree::PaymentMethod::BankTransfer' })
  }

  if base.whitelisted_ransackable_attributes.exclude?('bank_name')
    base.whitelisted_ransackable_attributes += %w[bank_name]
  end
end

Instance Method Details

#bank_transfer_payment?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'app/models/spree_bank_transfer/payment_decorator.rb', line 28

def bank_transfer_payment?
  payment_method.is_a?(Spree::PaymentMethod::BankTransfer)
end

#details_submitted?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'app/models/spree_bank_transfer/payment_decorator.rb', line 32

def 
  bank_name?
end