Class: Spree::Gateway::Bogus
Constant Summary
collapse
- TEST_VISA =
['4111111111111111','4012888888881881','4222222222222']
- TEST_MC =
['5500000000000004','5555555555554444','5105105105105100']
- TEST_AMEX =
['378282246310005','371449635398431','378734493671000','340000000000009']
- TEST_DISC =
['6011000000000004','6011111111111117','6011000990139424']
- VALID_CCS =
['1', TEST_VISA, TEST_MC, TEST_AMEX, TEST_DISC].flatten
PaymentMethod::DISPLAY
Instance Attribute Summary collapse
Instance Method Summary
collapse
-
#actions ⇒ Object
-
#authorize(money, credit_card, options = {}) ⇒ Object
-
#capture(money, authorization, gateway_options) ⇒ Object
-
#create_profile(payment) ⇒ Object
-
#credit(money, credit_card, response_code, options = {}) ⇒ Object
-
#payment_profiles_supported? ⇒ Boolean
-
#preferences ⇒ Object
-
#provider_class ⇒ Object
-
#purchase(money, credit_card, options = {}) ⇒ Object
-
#test? ⇒ Boolean
-
#void(response_code, credit_card, options = {}) ⇒ Object
current, #disable_customer_profile, #method_missing, #method_type, #options, #payment_source_class, #provider, #reusable_sources, #sources_by_order, #supports?
active?, #auto_capture?, available, find_with_destroyed, #method_type, #payment_source_class, providers, #reusable_sources, #source_required?, #supports?
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Spree::Gateway
Instance Attribute Details
#test ⇒ Object
Returns the value of attribute test.
10
11
12
|
# File 'app/models/spree/gateway/bogus.rb', line 10
def test
@test
end
|
Instance Method Details
#actions ⇒ Object
71
72
73
|
# File 'app/models/spree/gateway/bogus.rb', line 71
def actions
%w(capture void credit)
end
|
#authorize(money, credit_card, options = {}) ⇒ Object
27
28
29
30
31
32
33
34
|
# File 'app/models/spree/gateway/bogus.rb', line 27
def authorize(money, credit_card, options = {})
profile_id = credit_card.gateway_customer_profile_id
if VALID_CCS.include? credit_card.number or (profile_id and profile_id.starts_with? 'BGS-')
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345', :avs_result => { :code => 'D' })
else
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', { :message => 'Bogus Gateway: Forced failure' }, :test => true)
end
end
|
#capture(money, authorization, gateway_options) ⇒ Object
49
50
51
52
53
54
55
56
|
# File 'app/models/spree/gateway/bogus.rb', line 49
def capture(money, authorization, gateway_options)
if authorization == '12345'
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true)
else
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', :error => 'Bogus Gateway: Forced failure', :test => true)
end
end
|
#create_profile(payment) ⇒ Object
20
21
22
23
24
25
|
# File 'app/models/spree/gateway/bogus.rb', line 20
def create_profile(payment)
if success = VALID_CCS.include?(payment.source.number)
payment.source.update_attributes(:gateway_customer_profile_id => generate_profile_id(success))
end
end
|
#credit(money, credit_card, response_code, options = {}) ⇒ Object
45
46
47
|
# File 'app/models/spree/gateway/bogus.rb', line 45
def credit(money, credit_card, response_code, options = {})
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345')
end
|
#payment_profiles_supported? ⇒ Boolean
67
68
69
|
# File 'app/models/spree/gateway/bogus.rb', line 67
def payment_profiles_supported?
true
end
|
#preferences ⇒ Object
16
17
18
|
# File 'app/models/spree/gateway/bogus.rb', line 16
def preferences
{}
end
|
#provider_class ⇒ Object
12
13
14
|
# File 'app/models/spree/gateway/bogus.rb', line 12
def provider_class
self.class
end
|
#purchase(money, credit_card, options = {}) ⇒ Object
36
37
38
39
40
41
42
43
|
# File 'app/models/spree/gateway/bogus.rb', line 36
def purchase(money, credit_card, options = {})
profile_id = credit_card.gateway_customer_profile_id
if VALID_CCS.include? credit_card.number or (profile_id and profile_id.starts_with? 'BGS-')
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345', :avs_result => { :code => 'M' })
else
ActiveMerchant::Billing::Response.new(false, 'Bogus Gateway: Forced failure', :message => 'Bogus Gateway: Forced failure', :test => true)
end
end
|
#test? ⇒ Boolean
62
63
64
65
|
# File 'app/models/spree/gateway/bogus.rb', line 62
def test?
true
end
|
#void(response_code, credit_card, options = {}) ⇒ Object
58
59
60
|
# File 'app/models/spree/gateway/bogus.rb', line 58
def void(response_code, credit_card, options = {})
ActiveMerchant::Billing::Response.new(true, 'Bogus Gateway: Forced success', {}, :test => true, :authorization => '12345')
end
|