lib/active_merchant/billing/gateways/payex.rb in activemerchant-1.44.1 vs lib/active_merchant/billing/gateways/payex.rb in activemerchant-1.45.0
- old
+ new
@@ -1,22 +1,25 @@
require "nokogiri"
+
module ActiveMerchant #:nodoc:
module Billing #:nodoc:
class PayexGateway < Gateway
- self.live_url = 'https://external.payex.com/'
- self.test_url = 'https://test-external.payex.com/'
+ class_attribute :live_external_url, :test_external_url, :live_confined_url, :test_confined_url
+ self.live_external_url = 'https://external.payex.com/'
+ self.test_external_url = 'https://test-external.payex.com/'
+
+ self.live_confined_url = 'https://confined.payex.com/'
+ self.test_confined_url = 'https://test-confined.payex.com/'
+
self.money_format = :cents
self.supported_countries = ['DK', 'FI', 'NO', 'SE']
self.supported_cardtypes = [:visa, :master, :american_express, :discover]
self.homepage_url = 'http://payex.com/'
self.display_name = 'Payex'
self.default_currency = "EUR"
- # NOTE: the PurchaseCC uses a different url for test transactions
- TEST_CONFINED_URL = 'https://test-confined.payex.com/'
-
TRANSACTION_STATUS = {
sale: '0',
initialize: '1',
credit: '2',
authorize: '3',
@@ -204,12 +207,12 @@
properties = {
accountNumber: @options[:account],
orderRef: order_ref,
transactionType: 1, # online payment
cardNumber: payment_method.number,
- cardNumberExpireMonth: "%02d" % payment_method.month,
- cardNumberExpireYear: "%02d" % payment_method.year,
+ cardNumberExpireMonth: format(payment_method.month, :two_digits),
+ cardNumberExpireYear: format(payment_method.year, :two_digits),
cardHolderName: payment_method.name,
cardNumberCVC: payment_method.verification_value
}
hash_fields = [:accountNumber, :orderRef, :transactionType, :cardNumber, :cardNumberExpireMonth,
:cardNumberExpireYear, :cardNumberCVC, :cardHolderName]
@@ -317,11 +320,18 @@
request = build_xml_request(soap_action, properties)
commit(soap_action, request)
end
def url_for(soap_action)
- base_url = test? ? (soap_action[:confined] ? TEST_CONFINED_URL : test_url) : live_url
- File.join(base_url, soap_action[:url])
+ File.join(base_url(soap_action), soap_action[:url])
+ end
+
+ def base_url(soap_action)
+ if soap_action[:confined]
+ test? ? test_confined_url : live_confined_url
+ else
+ test? ? test_external_url : live_external_url
+ end
end
# this will add a hash to the passed in properties as required by Payex requests
def add_request_hash(properties, fields)
data = fields.map { |e| properties[e] }