Class: ActiveMerchant::Billing::BogusGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::BogusGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/bogus.rb
Overview
Instance Attribute Summary
Attributes inherited from Gateway
#options
Class Method Summary
collapse
Instance Method Summary
collapse
-
#authorize(money, creditcard, options = {}) ⇒ Object
-
#capture(money, ident, options = {}) ⇒ Object
-
#credit(money, ident, options = {}) ⇒ Object
-
#purchase(money, creditcard, options = {}) ⇒ Object
-
#store(creditcard, options = {}) ⇒ Object
-
#unstore(identification, options = {}) ⇒ Object
Methods inherited from Gateway
gateway, #initialize, supports?, #test?
#requires!
Methods included from PostsData
#included?, #ssl_post
Class Method Details
.supported_cardtypes ⇒ Object
We support visa and master card
73
74
75
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 73
def self.supported_cardtypes
[:bogus]
end
|
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 6
def authorize(money, creditcard, options = {})
case creditcard.number
when '1'
Response.new(true, "Bogus Gateway: Forced success", {:authorized_amount => money.to_s}, :test => true, :authorization => '53433' )
when '2'
Response.new(false, "Bogus Gateway: Forced failure", {:authorized_amount => money.to_s, :error => 'Bogus Gateway: Forced failure' }, :test => true)
else
raise Error, 'Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error'
end
end
|
#capture(money, ident, options = {}) ⇒ Object
39
40
41
42
43
44
45
46
47
48
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 39
def capture(money, ident, options = {})
case ident
when '1'
raise Error, 'Bogus Gateway: Use authorization number 1 for exception, 2 for error and anything else for success'
when '2'
Response.new(false, "Bogus Gateway: Forced failure", {:paid_amount => money.to_s, :error => 'Bogus Gateway: Forced failure' }, :test => true)
else
Response.new(true, "Bogus Gateway: Forced success", {:paid_amount => money.to_s}, :test => true)
end
end
|
#credit(money, ident, options = {}) ⇒ Object
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 28
def credit(money, ident, options = {})
case ident
when '1'
Response.new(true, "Bogus Gateway: Forced success", {:paid_amount => money.to_s}, :test => true)
when '2'
Response.new(false, "Bogus Gateway: Forced failure", {:paid_amount => money.to_s, :error => 'Bogus Gateway: Forced failure' },:test => true)
else
raise Error, 'Bogus Gateway: Use trans_id 1 for success, 2 for exception and anything else for error'
end
end
|
#purchase(money, creditcard, options = {}) ⇒ Object
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 17
def purchase(money, creditcard, options = {})
case creditcard.number
when '1'
Response.new(true, "Bogus Gateway: Forced success", {:paid_amount => money.to_s}, :test => true)
when '2'
Response.new(false, "Bogus Gateway: Forced failure", {:paid_amount => money.to_s, :error => 'Bogus Gateway: Forced failure' },:test => true)
else
raise Error, 'Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error'
end
end
|
#store(creditcard, options = {}) ⇒ Object
50
51
52
53
54
55
56
57
58
59
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 50
def store(creditcard, options = {})
case creditcard.number
when '1'
Response.new(true, "Bogus Gateway: Forced success", {:billingid => '1'}, :test => true, :authorization => '53433' )
when '2'
Response.new(false, "Bogus Gateway: Forced failure", {:billingid => nil, :error => 'Bogus Gateway: Forced failure' }, :test => true)
else
raise Error, 'Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error'
end
end
|
#unstore(identification, options = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
|
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 61
def unstore(identification, options = {})
case identification
when '1'
Response.new(true, "Bogus Gateway: Forced success", {}, :test => true)
when '2'
Response.new(false, "Bogus Gateway: Forced failure", {:error => 'Bogus Gateway: Forced failure' },:test => true)
else
raise Error, 'Bogus Gateway: Use trans_id 1 for success, 2 for exception and anything else for error'
end
end
|