Skip to content

Commit

Permalink
Renamed ProtxGateway to SagePayGateway due to rebranding; Updated end…
Browse files Browse the repository at this point in the history
…point URL's.
  • Loading branch information
Jesse Storimer committed Jul 30, 2009
1 parent 3877160 commit 65a878b
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 34 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -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]
Expand Down
@@ -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 = {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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

2 changes: 1 addition & 1 deletion test/fixtures.yml
Expand Up @@ -135,7 +135,7 @@ plugnpay:
login: LOGIN
password: PASSWORD

protx:
sage_pay:
login: LOGIN

# Working credentials, no need to replace
Expand Down
@@ -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',
Expand Down Expand Up @@ -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)
Expand Down
@@ -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'
)

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 65a878b

Please sign in to comment.