class ActiveMerchant::Billing::RealexDevelopmentGateway
Realex Development Gateway
Because the Realex gateway does not have a separate :test environment, we are unable to really work with it in a development environment.
The Bogus gateway was my initial choice for testing, however it does not take valid card data as giving successful responses therefore not enabling it to work if you have significant pre-validation of card data.
Realex also expects some extra parameters and therefore I thought it better to encapsulate them all here in a working development gateway that will act like Realex in production.
Constants
- AUTHORIZATION
- CAPTURE_ERROR_MESSAGE
- CREDIT_ERROR_MESSAGE
- ERROR_MESSAGE
- FAILING_CARD
- FAILURE_MESSAGE
- SUCCESSFUL_CARD
- SUCCESS_MESSAGE
- UNSTORE_ERROR_MESSAGE
- VOID_ERROR_MESSAGE
Public Instance Methods
capture(money, ident, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 69 def capture(money, ident, options = {}) 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 = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 58 def credit(money, ident, options = {}) 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, :orderid => '1234'}, :test => true) end end
purchase(money, creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 47 def purchase(money, creditcard, options = {}) case creditcard.number when SUCCESSFUL_CARD Response.new(true, SUCCESS_MESSAGE, {:paid_amount => money.to_s, :pasref => '1234'}, :test => true, :authorization => AUTHORIZATION) when FAILING_CARD Response.new(false, FAILURE_MESSAGE, {:paid_amount => money.to_s, :error => FAILURE_MESSAGE },:test => true) else raise Error, ERROR_MESSAGE end end
store(creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 91 def store(creditcard, options = {}) case creditcard.number when SUCCESSFUL_CARD Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION ) when FAILING_CARD Response.new(false, FAILURE_MESSAGE, {:billingid => nil, :error => FAILURE_MESSAGE }, :test => true) else raise Error, ERROR_MESSAGE end end
store_user(options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 106 def store_user(options = {}) Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION ) end
unstore(creditcard, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 102 def unstore(creditcard, options = {}) Response.new(true, SUCCESS_MESSAGE, {:billingid => '1'}, :test => true, :authorization => AUTHORIZATION ) end
void(ident, options = {})
click to toggle source
# File lib/active_merchant/billing/gateways/realex3ds_development.rb, line 80 def void(ident, options = {}) 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