lib/active_merchant/billing/gateways/sage_pay.rb in activemerchant-1.26.0 vs lib/active_merchant/billing/gateways/sage_pay.rb in activemerchant-1.27.0
- old
+ new
@@ -1,15 +1,17 @@
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class SagePayGateway < Gateway
cattr_accessor :simulate
self.simulate = false
+
+ class_attribute :simulator_url
+
+ self.test_url = 'https://test.sagepay.com/gateway/service'
+ self.live_url = 'https://live.sagepay.com/gateway/service'
+ self.simulator_url = 'https://test.sagepay.com/Simulator'
- 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 = {
:purchase => 'PAYMENT',
:credit => 'REFUND',
@@ -263,15 +265,15 @@
simulate ? build_simulator_url(action) : build_url(action)
end
def build_url(action)
endpoint = [ :purchase, :authorization ].include?(action) ? "vspdirect-register" : TRANSACTIONS[action].downcase
- "#{test? ? TEST_URL : LIVE_URL}/#{endpoint}.vsp"
+ "#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
end
def build_simulator_url(action)
endpoint = [ :purchase, :authorization ].include?(action) ? "VSPDirectGateway.asp" : "VSPServerGateway.asp?Service=Vendor#{TRANSACTIONS[action].capitalize}Tx"
- "#{SIMULATOR_URL}/#{endpoint}"
+ "#{self.simulator_url}/#{endpoint}"
end
def message_from(response)
response['Status'] == APPROVED ? 'Success' : (response['StatusDetail'] || 'Unspecified error') # simonr 20080207 can't actually get non-nil blanks, so this is shorter
end