From 65a878b9d734095ef998eab93e039d1bee30c0f1 Mon Sep 17 00:00:00 2001 From: Jesse Storimer Date: Mon, 6 Jul 2009 16:07:11 -0400 Subject: [PATCH] Renamed ProtxGateway to SagePayGateway due to rebranding; Updated endpoint URL's. --- CHANGELOG | 1 + .../gateways/{protx.rb => sage_pay.rb} | 17 +++++---- test/fixtures.yml | 2 +- ..._protx_test.rb => remote_sage_pay_test.rb} | 12 +++--- .../{protx_test.rb => sage_pay_test.rb} | 38 +++++++++---------- 5 files changed, 36 insertions(+), 34 deletions(-) rename lib/active_merchant/billing/gateways/{protx.rb => sage_pay.rb} (96%) rename test/remote/gateways/{remote_protx_test.rb => remote_sage_pay_test.rb} (92%) rename test/unit/gateways/{protx_test.rb => sage_pay_test.rb} (73%) diff --git a/CHANGELOG b/CHANGELOG index 78309febe69..c88bd23e844 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -3,6 +3,7 @@ * Add support for the Antigua based FirstPay payment gateway [Phil R] * Add support for PayPal reference transactions [kevin, John, Rahsun McAfee] * Add support for the MerchantWARE payment gateway [cody] +* Rename Protx to SagePay [jstorimer] * Allow test mode for eWay gateway [Duff OMelia] * Don't use Time.parse for the ExpiryDate [cody] * Add support for CVV code to Authorize.net CIM [Guy Naor] diff --git a/lib/active_merchant/billing/gateways/protx.rb b/lib/active_merchant/billing/gateways/sage_pay.rb similarity index 96% rename from lib/active_merchant/billing/gateways/protx.rb rename to lib/active_merchant/billing/gateways/sage_pay.rb index 11bb00a4f93..e464c37d91d 100644 --- a/lib/active_merchant/billing/gateways/protx.rb +++ b/lib/active_merchant/billing/gateways/sage_pay.rb @@ -1,13 +1,13 @@ module ActiveMerchant #:nodoc: module Billing #:nodoc: - class ProtxGateway < Gateway + class SagePayGateway < Gateway cattr_accessor :simulate self.simulate = false - TEST_URL = 'https://ukvpstest.protx.com/vspgateway/service' - LIVE_URL = 'https://ukvps.protx.com/vspgateway/service' - SIMULATOR_URL = 'https://ukvpstest.protx.com/VSPSimulator' - + TEST_URL = 'https://test.sagepay.com/gateway/service' + LIVE_URL = 'https://live.sagepay.com/gateway/service' + SIMULATOR_URL = 'https://test.sagepay.com/Simulator' + APPROVED = 'OK' TRANSACTIONS = { @@ -45,8 +45,8 @@ class ProtxGateway < Gateway self.supported_countries = ['GB'] self.default_currency = 'GBP' - self.homepage_url = 'http://www.protx.com' - self.display_name = 'Protx' + self.homepage_url = 'http://www.sagepay.com' + self.display_name = 'SagePay' def initialize(options = {}) requires!(options, :login) @@ -281,7 +281,7 @@ def post_data(action, parameters = {}) parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&") end - # Protx returns data in the following format + # SagePay returns data in the following format # Key1=value1 # Key2=value2 def parse(body) @@ -302,6 +302,7 @@ def parse_first_and_last_name(value) [ first_name[0,20], last_name[0,20] ] end end + ProtxGateway = SagePayGateway end end diff --git a/test/fixtures.yml b/test/fixtures.yml index f137f357e9e..8354acc5080 100644 --- a/test/fixtures.yml +++ b/test/fixtures.yml @@ -135,7 +135,7 @@ plugnpay: login: LOGIN password: PASSWORD -protx: +sage_pay: login: LOGIN # Working credentials, no need to replace diff --git a/test/remote/gateways/remote_protx_test.rb b/test/remote/gateways/remote_sage_pay_test.rb similarity index 92% rename from test/remote/gateways/remote_protx_test.rb rename to test/remote/gateways/remote_sage_pay_test.rb index 8abd2011d47..4bb3a2864bc 100644 --- a/test/remote/gateways/remote_protx_test.rb +++ b/test/remote/gateways/remote_sage_pay_test.rb @@ -1,15 +1,15 @@ require 'test_helper' -# Some of the standard tests have been removed at Protx test +# Some of the standard tests have been removed at SagePay test # server is pants and accepts anything and says Status=OK. (shift) # The tests for American Express will only pass if your account is # American express enabled. -class RemoteProtxTest < Test::Unit::TestCase +class RemoteSagePayTest < Test::Unit::TestCase # set to true to run the tests in the simulated environment - ProtxGateway.simulate = false + SagePayGateway.simulate = false def setup - @gateway = ProtxGateway.new(fixtures(:protx)) + @gateway = SagePayGateway.new(fixtures(:sage_pay)) @amex = CreditCard.new( :number => '374200000000004', @@ -201,9 +201,9 @@ def test_successful_electron_purchase end def test_invalid_login - message = ProtxGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.' + message = SagePayGateway.simulate ? 'VSP Simulator cannot find your vendor name. Ensure you have have supplied a Vendor field with your VSP Vendor name assigned to it.' : '3034 : The Vendor or VendorName value is required.' - gateway = ProtxGateway.new( + gateway = SagePayGateway.new( :login => '' ) assert response = gateway.purchase(@amount, @mastercard, @options) diff --git a/test/unit/gateways/protx_test.rb b/test/unit/gateways/sage_pay_test.rb similarity index 73% rename from test/unit/gateways/protx_test.rb rename to test/unit/gateways/sage_pay_test.rb index 5369b1b157d..87d79997989 100644 --- a/test/unit/gateways/protx_test.rb +++ b/test/unit/gateways/sage_pay_test.rb @@ -1,8 +1,8 @@ require 'test_helper' -class ProtxTest < Test::Unit::TestCase +class SagePayTest < Test::Unit::TestCase def setup - @gateway = ProtxGateway.new( + @gateway = SagePayGateway.new( :login => 'X' ) @@ -44,50 +44,50 @@ def test_unsuccessful_purchase end def test_purchase_url - assert_equal 'https://ukvpstest.protx.com/vspgateway/service/vspdirect-register.vsp', @gateway.send(:url_for, :purchase) + assert_equal 'https://test.sagepay.com/gateway/service/vspdirect-register.vsp', @gateway.send(:url_for, :purchase) end def test_capture_url - assert_equal 'https://ukvpstest.protx.com/vspgateway/service/release.vsp', @gateway.send(:url_for, :capture) + assert_equal 'https://test.sagepay.com/gateway/service/release.vsp', @gateway.send(:url_for, :capture) end def test_electron_cards # Visa range - assert_no_match ProtxGateway::ELECTRON, '4245180000000000' + assert_no_match SagePayGateway::ELECTRON, '4245180000000000' # First electron range - assert_match ProtxGateway::ELECTRON, '4245190000000000' + assert_match SagePayGateway::ELECTRON, '4245190000000000' # Second range - assert_match ProtxGateway::ELECTRON, '4249620000000000' - assert_match ProtxGateway::ELECTRON, '4249630000000000' + assert_match SagePayGateway::ELECTRON, '4249620000000000' + assert_match SagePayGateway::ELECTRON, '4249630000000000' # Third - assert_match ProtxGateway::ELECTRON, '4508750000000000' + assert_match SagePayGateway::ELECTRON, '4508750000000000' # Fourth - assert_match ProtxGateway::ELECTRON, '4844060000000000' - assert_match ProtxGateway::ELECTRON, '4844080000000000' + assert_match SagePayGateway::ELECTRON, '4844060000000000' + assert_match SagePayGateway::ELECTRON, '4844080000000000' # Fifth - assert_match ProtxGateway::ELECTRON, '4844110000000000' - assert_match ProtxGateway::ELECTRON, '4844550000000000' + assert_match SagePayGateway::ELECTRON, '4844110000000000' + assert_match SagePayGateway::ELECTRON, '4844550000000000' # Sixth - assert_match ProtxGateway::ELECTRON, '4917300000000000' - assert_match ProtxGateway::ELECTRON, '4917590000000000' + assert_match SagePayGateway::ELECTRON, '4917300000000000' + assert_match SagePayGateway::ELECTRON, '4917590000000000' # Seventh - assert_match ProtxGateway::ELECTRON, '4918800000000000' + assert_match SagePayGateway::ELECTRON, '4918800000000000' # Visa - assert_no_match ProtxGateway::ELECTRON, '4918810000000000' + assert_no_match SagePayGateway::ELECTRON, '4918810000000000' # 19 PAN length - assert_match ProtxGateway::ELECTRON, '4249620000000000000' + assert_match SagePayGateway::ELECTRON, '4249620000000000000' # 20 PAN length - assert_no_match ProtxGateway::ELECTRON, '42496200000000000' + assert_no_match SagePayGateway::ELECTRON, '42496200000000000' end def test_avs_result