Class: PaymentMethod

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/payment_method.rb

Direct Known Subclasses

BillingIntegration, Gateway, Check

Defined Under Namespace

Classes: Check

Constant Summary collapse

DISPLAY =
[:both, :front_end, :back_end]
@@providers =
Set.new

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.active?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/payment_method.rb', line 30

def self.active?
  self.count(:conditions => {:type => self.to_s, :environment => Rails.env, :active => true}) > 0
end

.available(display_on = 'both') ⇒ Object



26
27
28
# File 'app/models/payment_method.rb', line 26

def self.available(display_on='both')
  PaymentMethod.all.select { |p| p.active && (p.display_on == display_on.to_s || p.display_on.blank?) &&  (p.environment == Rails.env || p.environment.blank?) }
end

.currentObject



34
35
36
# File 'app/models/payment_method.rb', line 34

def self.current
  PaymentMethod.find(:first, :conditions => {:active => true, :environment => Rails.env})
end

.find_with_destroyed(*args) ⇒ Object



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

def self.find_with_destroyed *args
  self.with_exclusive_scope { find(*args) }
end

.providersObject



11
12
13
# File 'app/models/payment_method.rb', line 11

def self.providers
  @@providers.to_a
end

.registerObject



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

def self.register
  @@providers.add(self)
end

Instance Method Details

#destroyObject



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

def destroy
  self.update_attribute(:deleted_at, Time.now.utc)
end

#method_typeObject



38
39
40
# File 'app/models/payment_method.rb', line 38

def method_type
  type.demodulize.downcase
end

#payment_profiles_supported?Boolean

Returns:

  • (Boolean)


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

def payment_profiles_supported?
  false
end

#payment_source_classObject

The class that will process payments for this payment type, used for @payment.source e.g. Creditcard in the case of a the Gateway payment type nil means the payment method doesn’t require a source e.g. check



22
23
24
# File 'app/models/payment_method.rb', line 22

def payment_source_class
  raise "You must implement payment_source_class method for this gateway."
end

#provider_classObject



15
16
17
# File 'app/models/payment_method.rb', line 15

def provider_class
  raise "You must implement provider_class method for this gateway."
end

#source_required?Boolean

Returns:

  • (Boolean)


53
54
55
# File 'app/models/payment_method.rb', line 53

def source_required?
 true
end