Class: ActiveMerchant::Billing::BogusGateway
- Defined in:
- lib/active_merchant/billing/gateways/bogus.rb
Overview
Bogus Gateway
Constant Summary collapse
- AUTHORIZATION =
'53433'- SUCCESS_MESSAGE =
"Bogus Gateway: Forced success"- FAILURE_MESSAGE =
"Bogus Gateway: Forced failure"- THREE_D_SECURE_MESSAGE =
"Bogus Gateway: Requires additional 3D secure authentication"- 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"- THREE_D_MD =
'md'- THREE_D_PA_REQ =
'pa_req'- THREE_D_PA_RES =
'pa_res'- THREE_D_ACS_URL =
'https://domain.com/3d_secure_page'
Constants inherited from Gateway
Instance Attribute Summary
Attributes inherited from Gateway
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
- #three_d_complete(pa_res, md) ⇒ Object
- #unstore(identification, options = {}) ⇒ Object
- #void(ident, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, inherited, #initialize, supports?, #test?
Methods included from Utils
Methods included from CreditCardFormatting
Methods included from RequiresParameters
Methods included from PostsData
Constructor Details
This class inherits a constructor from ActiveMerchant::Billing::Gateway
Instance Method Details
#authorize(money, creditcard, options = {}) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 27 def (money, creditcard, = {}) case creditcard.number when '1' Response.new(true, SUCCESS_MESSAGE, {:authorized_amount => money.to_s}, :test => true, :authorization => AUTHORIZATION ) when '2' Response.new(false, FAILURE_MESSAGE, {:authorized_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true) when '4' Response.new(false, THREE_D_SECURE_MESSAGE, {:authorized_amount => money.to_s}, :three_d_secure => true, :pa_req => THREE_D_PA_REQ, :md => THREE_D_MD, :acs_url => THREE_D_ACS_URL, :test => true) else raise Error, ERROR_MESSAGE end end |
#capture(money, ident, options = {}) ⇒ Object
72 73 74 75 76 77 78 79 80 81 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 72 def capture(money, ident, = {}) case ident when '1' raise Error, CAPTURE_ERROR_MESSAGE when '2' Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true) else Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true) end end |
#credit(money, ident, options = {}) ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 61 def credit(money, ident, = {}) case ident when '1' raise Error, CREDIT_ERROR_MESSAGE when '2' Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE }, :test => true) else Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true) end end |
#purchase(money, creditcard, options = {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 40 def purchase(money, creditcard, = {}) case creditcard.number when '1' Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s}, :test => true) when '2' Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE },:test => true) when '4' Response.new(false, THREE_D_SECURE_MESSAGE, {:paid_amount => money.to_s}, :three_d_secure => true, :pa_req => THREE_D_PA_REQ, :md => THREE_D_MD, :acs_url => THREE_D_ACS_URL, :test => true) else raise Error, ERROR_MESSAGE end end |
#store(creditcard, options = {}) ⇒ Object
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 94 def store(creditcard, = {}) case creditcard.number when '1' Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION ) when '2' Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true) else raise Error, ERROR_MESSAGE end end |
#three_d_complete(pa_res, md) ⇒ Object
53 54 55 56 57 58 59 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 53 def three_d_complete(pa_res, md) if pa_res == THREE_D_PA_RES && md == THREE_D_MD Response.new(true, SUCCESS_MESSAGE, {}, :test => true, :authorization => AUTHORIZATION) else Response.new(false, FAILURE_MESSAGE, {},:test => true) end end |
#unstore(identification, options = {}) ⇒ Object
105 106 107 108 109 110 111 112 113 114 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 105 def unstore(identification, = {}) case identification when '1' Response.new(true, SUCCESS_MESSAGE, {}, :test => true) when '2' Response.new(false, FAILURE_MESSAGE, {:error => FAILURE_MESSAGE },:test => true) else raise Error, UNSTORE_ERROR_MESSAGE end end |
#void(ident, options = {}) ⇒ Object
83 84 85 86 87 88 89 90 91 92 |
# File 'lib/active_merchant/billing/gateways/bogus.rb', line 83 def void(ident, = {}) case ident when '1' raise Error, VOID_ERROR_MESSAGE when '2' Response.new(false, FAILURE_MESSAGE, {:authorization => ident, :error => FAILURE_MESSAGE }, :test => true) else Response.new(true, SUCCESS_MESSAGE, {:authorization => ident}, :test => true) end end |