| Class | ActiveMerchant::Billing::BogusGateway |
| In: |
lib/active_merchant/billing/gateways/bogus.rb
|
| Parent: | Gateway |
| AUTHORIZATION | = | '53433' |
| SUCCESS_MESSAGE | = | "Bogus Gateway: Forced success" |
| FAILURE_MESSAGE | = | "Bogus Gateway: Forced failure" |
| ERROR_MESSAGE | = | "Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error" |
| CREDIT_ERROR_MESSAGE | = | "Bogus Gateway: Use trans_id 1 for success, 2 for exception and anything else for error" |
| UNSTORE_ERROR_MESSAGE | = | "Bogus Gateway: Use trans_id 1 for success, 2 for exception and anything else for error" |
| CAPTURE_ERROR_MESSAGE | = | "Bogus Gateway: Use authorization number 1 for exception, 2 for error and anything else for success" |
| VOID_ERROR_MESSAGE | = | "Bogus Gateway: Use authorization number 1 for exception, 2 for error and anything else for success" |
# File lib/active_merchant/billing/gateways/bogus.rb, line 20
20: def authorize(money, creditcard, options = {})
21: money = amount(money)
22: case creditcard.number
23: when '1'
24: Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money}, :test => true, :authorization => AUTHORIZATION )
25: when '2'
26: Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money, :error => FAILURE_MESSAGE }, :test => true)
27: else
28: raise Error, ERROR_MESSAGE
29: end
30: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 56
56: def capture(money, ident, options = {})
57: money = amount(money)
58: case ident
59: when '1'
60: raise Error, CAPTURE_ERROR_MESSAGE
61: when '2'
62: Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
63: else
64: Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
65: end
66: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 44
44: def credit(money, ident, options = {})
45: money = amount(money)
46: case ident
47: when '1'
48: raise Error, CREDIT_ERROR_MESSAGE
49: when '2'
50: Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE }, :test => true)
51: else
52: Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
53: end
54: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 32
32: def purchase(money, creditcard, options = {})
33: money = amount(money)
34: case creditcard.number
35: when '1'
36: Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money}, :test => true)
37: when '2'
38: Response.new(false, FAILURE_MESSAGE, {:paid_amount => money, :error => FAILURE_MESSAGE },:test => true)
39: else
40: raise Error, ERROR_MESSAGE
41: end
42: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 79
79: def store(creditcard, options = {})
80: case creditcard.number
81: when '1'
82: Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION )
83: when '2'
84: Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true)
85: else
86: raise Error, ERROR_MESSAGE
87: end
88: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 90
90: def unstore(identification, options = {})
91: case identification
92: when '1'
93: Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
94: when '2'
95: Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE },:test => true)
96: else
97: raise Error, UNSTORE_ERROR_MESSAGE
98: end
99: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 68
68: def void(ident, options = {})
69: case ident
70: when '1'
71: raise Error, VOID_ERROR_MESSAGE
72: when '2'
73: Response.new(false, FAILURE_MESSAGE, {:authorization => ident, :error => FAILURE_MESSAGE }, :test => true)
74: else
75: Response.new(true, SUCCESS_MESSAGE, {:authorization => ident}, :test => true)
76: end
77: end