Permalink
Browse files

Refactor to use passed in option instead of instance method

  • Loading branch information...
mikel committed Apr 10, 2012
1 parent 1fab5fa commit 45682c0dfe33cfabfabad503bd3448ca03cd5b1f
Showing with 12 additions and 11 deletions.
  1. +11 −10 lib/active_merchant/billing/gateways/payment_express.rb
  2. +1 −1 test/unit/gateways/payment_express_test.rb
@@ -21,11 +21,8 @@ class PaymentExpressGateway < Gateway
self.homepage_url = 'http://www.paymentexpress.com/'
self.display_name = 'PaymentExpress'
- # Use "BillingId" for the Token type. If set to false, then the token will be sent
- # as the DPS specified "DpsBillingId". This is per the documentation at
- # http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling
- attr_accessor :use_billing_id_for_token
- alias :use_billing_id_for_token? :use_billing_id_for_token
+ attr_reader :use_custom_payment_token
+ alias :use_custom_payment_token? :use_custom_payment_token
URL = 'https://sec.paymentexpress.com/pxpost.aspx'
@@ -41,8 +38,12 @@ class PaymentExpressGateway < Gateway
# We require the DPS gateway username and password when the object is created.
def initialize(options = {})
- # A DPS username and password must exist
+ # A DPS username and password must exist
requires!(options, :login, :password)
+ # Use "BillingId" for the Token type. If set to false, then the token will be sent
+ # as the DPS specified "DpsBillingId". This is per the documentation at
+ # http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling
+ @use_custom_payment_token = !!options[:use_custom_payment_token]
# Make the options an instance variable
@options = options
super
@@ -107,14 +108,14 @@ def credit(money, identification, options = {})
# Firstly, pass in a `:billing_id` as an option in the hash of this store method. No
# validation is done on this BillingId by PaymentExpress so you must ensure that it is unique.
#
- # Secondly, you will need to pass in the option `{:use_billing_id_for_token => true}` when
+ # Secondly, you will need to pass in the option `{:use_custom_payment_token => true}` when
# initializing your gateway instance, like so:
#
# gateway = ActiveMerchant::Billing::PaymentExpressGateway.new(
# :login => 'USERNAME',
- # :password => 'PASSWORD'
+ # :password => 'PASSWORD',
+ # :use_custom_payment_token => true
# )
- # gateway.use_billing_id_for_token = true
#
# see: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#Tokenbilling
#
@@ -183,7 +184,7 @@ def add_credit_card(xml, credit_card)
end
def add_billing_token(xml, token)
- if use_billing_id_for_token?
+ if use_custom_payment_token?
xml.add_element("BillingId").text = token
else
xml.add_element("DpsBillingId").text = token
@@ -102,7 +102,7 @@ def test_purchase_using_merchant_specified_billing_id_token
@gateway = PaymentExpressGateway.new(
:login => 'LOGIN',
:password => 'PASSWORD',
- :use_billing_id_for_token => true
+ :use_custom_payment_token => true
)
@gateway.expects(:ssl_post).returns( successful_store_response({:billing_id => 'TEST1234'}) )

0 comments on commit 45682c0

Please sign in to comment.