Class: Spree::Gateway
Direct Known Subclasses
Bogus
Defined Under Namespace
Classes: Bogus, BogusSimple
Constant Summary
PaymentMethod::DISPLAY
Class Method Summary
collapse
-
.current ⇒ Object
instantiates the selected gateway and configures with the options stored in the database.
Instance Method Summary
collapse
active?, #auto_capture?, available, #cancel, find_with_destroyed, #provider_class, providers, #source_required?, #store_credit?
#preference_source=, #preferences, #preferences=
Methods inherited from Base
page
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Class Method Details
.current ⇒ Object
instantiates the selected gateway and configures with the options stored in the database
15
16
17
|
# File 'app/models/spree/gateway.rb', line 15
def self.current
super
end
|
Instance Method Details
#disable_customer_profile(source) ⇒ Object
46
47
48
49
50
51
52
|
# File 'app/models/spree/gateway.rb', line 46
def disable_customer_profile(source)
if source.is_a? CreditCard
source.update_column :gateway_customer_profile_id, nil
else
raise 'You must implement disable_customer_profile method for this gateway.'
end
end
|
#method_type ⇒ Object
36
37
38
|
# File 'app/models/spree/gateway.rb', line 36
def method_type
'gateway'
end
|
#options ⇒ Object
28
29
30
|
# File 'app/models/spree/gateway.rb', line 28
def options
preferences.to_hash
end
|
#payment_profiles_supported? ⇒ Boolean
32
33
34
|
# File 'app/models/spree/gateway.rb', line 32
def payment_profiles_supported?
false
end
|
#payment_source_class ⇒ Object
10
11
12
|
# File 'app/models/spree/gateway.rb', line 10
def payment_source_class
CreditCard
end
|
#provider ⇒ Object
19
20
21
22
23
24
25
26
|
# File 'app/models/spree/gateway.rb', line 19
def provider
gateway_options = options
gateway_options.delete :login if gateway_options.has_key?(:login) and gateway_options[:login].nil?
if gateway_options[:server]
ActiveMerchant::Billing::Base.gateway_mode = gateway_options[:server].to_sym
end
@provider ||= provider_class.new(gateway_options)
end
|
#reusable_sources(order) ⇒ Object
59
60
61
62
63
64
65
66
67
68
69
|
# File 'app/models/spree/gateway.rb', line 59
def reusable_sources(order)
if order.completed?
sources_by_order order
else
if order.user_id
self.credit_cards.where(user_id: order.user_id).with_payment_profile
else
[]
end
end
end
|
#sources_by_order(order) ⇒ Object
54
55
56
57
|
# File 'app/models/spree/gateway.rb', line 54
def sources_by_order(order)
source_ids = order.payments.where(payment_method_id: self.id).pluck(:source_id).uniq
payment_source_class.where(id: source_ids).with_payment_profile
end
|
#supports?(source) ⇒ Boolean
40
41
42
43
44
|
# File 'app/models/spree/gateway.rb', line 40
def supports?(source)
return true unless provider_class.respond_to? :supports?
return false unless source.brand
provider_class.supports?(source.brand)
end
|