Class: Spree::Gateway
Direct Known Subclasses
Bogus
Defined Under Namespace
Classes: Bogus, BogusSimple
Constant Summary
PaymentMethod::DISPLAY
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
display_includes, #initialize_preference_defaults, page, preference
#default_preferences, #defined_preferences, #get_preference, #has_preference!, #has_preference?, #preference_default, #preference_type, #set_preference
Instance Method Details
#disable_customer_profile(source) ⇒ Object
41
42
43
44
45
46
47
48
|
# File 'app/models/spree/gateway.rb', line 41
def disable_customer_profile(source)
Spree::Deprecation.warn("Gateway#disable_customer_profile is deprecated")
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
31
32
33
|
# File 'app/models/spree/gateway.rb', line 31
def method_type
'gateway'
end
|
#options ⇒ Object
23
24
25
|
# File 'app/models/spree/gateway.rb', line 23
def options
preferences.to_hash
end
|
#payment_profiles_supported? ⇒ Boolean
27
28
29
|
# File 'app/models/spree/gateway.rb', line 27
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
14
15
16
17
18
19
20
21
|
# File 'app/models/spree/gateway.rb', line 14
def provider
gateway_options = options
gateway_options.delete :login if gateway_options.key?(:login) && gateway_options[:login].nil?
if gateway_options[:server]
ActiveMerchant::Billing::Base.mode = gateway_options[:server].to_sym
end
@provider ||= provider_class.new(gateway_options)
end
|
#reusable_sources(order) ⇒ Object
55
56
57
58
59
60
61
62
63
|
# File 'app/models/spree/gateway.rb', line 55
def reusable_sources(order)
if order.completed?
sources_by_order(order)
elsif order.user_id
credit_cards.where(user_id: order.user_id).with_payment_profile
else
[]
end
end
|
#sources_by_order(order) ⇒ Object
50
51
52
53
|
# File 'app/models/spree/gateway.rb', line 50
def sources_by_order(order)
source_ids = order.payments.where(payment_method_id: id).pluck(:source_id).uniq
payment_source_class.where(id: source_ids).with_payment_profile
end
|
#supports?(source) ⇒ Boolean
35
36
37
38
39
|
# File 'app/models/spree/gateway.rb', line 35
def supports?(source)
return true unless provider_class.respond_to? :supports?
return true if source.brand && provider_class.supports?(source.brand)
source.has_payment_profile?
end
|