| 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" |
# File lib/active_merchant/billing/gateways/bogus.rb, line 19
19: def authorize(money, creditcard, options = {})
20: case creditcard.number
21: when '1'
22: Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money.to_s}, :test => true, :authorization => AUTHORIZATION )
23: when '2'
24: Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true)
25: else
26: raise Error, ERROR_MESSAGE
27: end
28: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 52
52: def capture(money, ident, options = {})
53: case ident
54: when '1'
55: raise Error, CAPTURE_ERROR_MESSAGE
56: when '2'
57: Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true)
58: else
59: Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true)
60: end
61: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 41
41: def credit(money, ident, options = {})
42: case ident
43: when '1'
44: raise Error, CREDIT_ERROR_MESSAGE
45: when '2'
46: Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true)
47: else
48: Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true)
49: end
50: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 30
30: def purchase(money, creditcard, options = {})
31: case creditcard.number
32: when '1'
33: Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true)
34: when '2'
35: Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE },:test => true)
36: else
37: raise Error, ERROR_MESSAGE
38: end
39: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 63
63: def store(creditcard, options = {})
64: case creditcard.number
65: when '1'
66: Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION )
67: when '2'
68: Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true)
69: else
70: raise Error, ERROR_MESSAGE
71: end
72: end
# File lib/active_merchant/billing/gateways/bogus.rb, line 74
74: def unstore(identification, options = {})
75: case identification
76: when '1'
77: Response.new(true, SUCCESS_MESSAGE, {}, :test => true)
78: when '2'
79: Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE },:test => true)
80: else
81: raise Error, UNSTORE_ERROR_MESSAGE
82: end
83: end