Skip to content

Commit 9775927

Browse files
committed
TNS, TransFirstTransactionExpress, USA EPAY: Normalize API versions
Normalize the use of API_VERSION for TNS, TransFirstTransactionExpress and USA EPAY gateways. Remote: TNS: 13 tests, 26 assertions, 9 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications 23.0769% passed TransFirstTransactionExpress: 34 tests, 0 assertions, 0 failures, 34 errors, 0 pendings, 0 omissions, 0 notifications 0% passed USA EPAY: USA EPAY advanced: 40 tests, 0 assertions, 0 failures, 40 errors, 0 pendings, 0 omissions, 0 notifications 0% passed USA EPAY transaction: 34 tests, 0 assertions, 0 failures, 34 errors, 0 pendings, 0 omissions, 0 notifications 0% passed
1 parent ce48fa9 commit 9775927

File tree

7 files changed

+94
-67
lines changed

7 files changed

+94
-67
lines changed

CHANGELOG

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@
184184
* Nuvei: Map order_id to clientUniqueId field on capture transactions [aaqibrashidmir] #5498
185185
* Ebanx: Added new GSF payment.taxes.iva_co [ritesh-spreedly] #5509
186186
* Litle: Remove 141 & 142 [almalee24] #5505
187+
* TNS/TransFirstTransactionExpress/USA EPAY: Normalize API_VERSION usage [sumit-sharmas] #5516
187188

188189
== Version 1.137.0 (August 2, 2024)
189190
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).

lib/active_merchant/billing/gateways/tns.rb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@ class TnsGateway < Gateway
55

66
class_attribute :live_na_url, :live_ap_url, :live_eu_url, :test_na_url, :test_ap_url, :test_eu_url
77

8-
VERSION = '52'
8+
version '52'
99

10-
self.live_na_url = "https://secure.na.tnspayments.com/api/rest/version/#{VERSION}/"
11-
self.live_ap_url = "https://secure.ap.tnspayments.com/api/rest/version/#{VERSION}/"
12-
self.live_eu_url = "https://secure.eu.tnspayments.com/api/rest/version/#{VERSION}/"
10+
self.live_na_url = "https://secure.na.tnspayments.com/api/rest/version/#{fetch_version}/"
11+
self.live_ap_url = "https://secure.ap.tnspayments.com/api/rest/version/#{fetch_version}/"
12+
self.live_eu_url = "https://secure.eu.tnspayments.com/api/rest/version/#{fetch_version}/"
1313

14-
self.test_url = "https://secure.uat.tnspayments.com/api/rest/version/#{VERSION}/"
14+
self.test_url = "https://secure.uat.tnspayments.com/api/rest/version/#{fetch_version}/"
1515

1616
self.display_name = 'TNS'
1717
self.homepage_url = 'http://www.tnsi.com/'

lib/active_merchant/billing/gateways/trans_first_transaction_express.rb

Lines changed: 63 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,20 @@
33
module ActiveMerchant # :nodoc:
44
module Billing # :nodoc:
55
class TransFirstTransactionExpressGateway < Gateway
6+
version 'v1'
7+
68
self.display_name = 'TransFirst Transaction Express'
79
self.homepage_url = 'http://transactionexpress.com/'
810

9-
self.test_url = 'https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl'
10-
self.live_url = 'https://ws.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl'
11+
self.test_url = "https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-#{fetch_version}?wsdl"
12+
self.live_url = "https://ws.transactionexpress.com/portal/merchantframework/MerchantWebServices-#{fetch_version}?wsdl"
1113

1214
self.supported_countries = ['US']
1315
self.default_currency = 'USD'
1416
self.money_format = :cents
1517
self.supported_cardtypes = %i[visa master american_express discover diners_club]
1618

17-
V1_NAMESPACE = 'http://postilion/realtime/merchantframework/xsd/v1/'
19+
V1_NAMESPACE = "http://postilion/realtime/merchantframework/xsd/#{fetch_version}/"
1820
SOAPENV_NAMESPACE = 'http://schemas.xmlsoap.org/soap/envelope/'
1921
AUTHORIZATION_FIELD_SEPARATOR = '|'
2022

@@ -295,10 +297,10 @@ def store(payment_method, options = {})
295297
customer_id = r.params['custId']
296298

297299
store_payment_method_request = build_xml_payment_storage_request do |doc|
298-
doc['v1'].cust do
300+
doc[fetch_version].cust do
299301
add_customer_id(doc, customer_id)
300-
doc['v1'].pmt do
301-
doc['v1'].type 0 # add
302+
doc[fetch_version].pmt do
303+
doc[fetch_version].type 0 # add
302304
add_credit_card(doc, payment_method)
303305
end
304306
end
@@ -459,7 +461,7 @@ def build_xml_request(wrapper, merchant_product_type = nil)
459461
Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
460462
xml['soapenv'].Envelope('xmlns:soapenv' => SOAPENV_NAMESPACE) do
461463
xml['soapenv'].Body do
462-
xml['v1'].send(wrapper, 'xmlns:v1' => V1_NAMESPACE) do
464+
xml[fetch_version].send(wrapper, "xmlns:#{fetch_version}" => V1_NAMESPACE) do
463465
add_merchant(xml)
464466
yield(xml)
465467
end
@@ -473,44 +475,44 @@ def add_transaction_code_to_request(request, action)
473475
return request if action == :store
474476

475477
doc = Nokogiri::XML::Document.parse(request)
476-
merc_nodeset = doc.xpath('//v1:merc', 'v1' => V1_NAMESPACE)
477-
merc_nodeset.after "<v1:tranCode>#{TRANSACTION_CODES[action]}</v1:tranCode>"
478+
merc_nodeset = doc.xpath("//#{fetch_version}:merc", fetch_version => V1_NAMESPACE)
479+
merc_nodeset.after "<#{fetch_version}:tranCode>#{TRANSACTION_CODES[action]}</#{fetch_version}:tranCode>"
478480
doc.root.to_xml
479481
end
480482

481483
def add_merchant(doc, product_type = nil)
482-
doc['v1'].merc do
483-
doc['v1'].id @options[:gateway_id]
484-
doc['v1'].regKey @options[:reg_key]
485-
doc['v1'].inType '1'
486-
doc['v1'].prodType product_type if product_type
484+
doc[fetch_version].merc do
485+
doc[fetch_version].id @options[:gateway_id]
486+
doc[fetch_version].regKey @options[:reg_key]
487+
doc[fetch_version].inType '1'
488+
doc[fetch_version].prodType product_type if product_type
487489
end
488490
end
489491

490492
def add_amount(doc, money)
491-
doc['v1'].reqAmt amount(money)
493+
doc[fetch_version].reqAmt amount(money)
492494
end
493495

494496
def add_order_number(doc, options)
495497
return unless options[:order_id]
496498

497-
doc['v1'].authReq {
498-
doc['v1'].ordNr options[:order_id]
499+
doc[fetch_version].authReq {
500+
doc[fetch_version].ordNr options[:order_id]
499501
}
500502
end
501503

502504
def add_credit_card(doc, payment_method)
503-
doc['v1'].card {
504-
doc['v1'].pan payment_method.number
505-
doc['v1'].sec payment_method.verification_value if payment_method.verification_value?
506-
doc['v1'].xprDt expiration_date(payment_method)
505+
doc[fetch_version].card {
506+
doc[fetch_version].pan payment_method.number
507+
doc[fetch_version].sec payment_method.verification_value if payment_method.verification_value?
508+
doc[fetch_version].xprDt expiration_date(payment_method)
507509
}
508510
end
509511

510512
def add_echeck(doc, payment_method)
511-
doc['v1'].achEcheck {
512-
doc['v1'].bankRtNr payment_method.routing_number
513-
doc['v1'].acctNr payment_method.account_number
513+
doc[fetch_version].achEcheck {
514+
doc[fetch_version].bankRtNr payment_method.routing_number
515+
doc[fetch_version].acctNr payment_method.account_number
514516
}
515517
end
516518

@@ -521,82 +523,82 @@ def expiration_date(payment_method)
521523
end
522524

523525
def add_pan(doc, payment_method)
524-
doc['v1'].card do
525-
doc['v1'].pan payment_method.number
526+
doc[fetch_version].card do
527+
doc[fetch_version].pan payment_method.number
526528
end
527529
end
528530

529531
def add_contact(doc, fullname, options)
530-
doc['v1'].contact do
531-
doc['v1'].fullName fullname unless fullname.blank?
532-
doc['v1'].coName options[:company_name] if options[:company_name]
533-
doc['v1'].title options[:title] if options[:title]
532+
doc[fetch_version].contact do
533+
doc[fetch_version].fullName fullname unless fullname.blank?
534+
doc[fetch_version].coName options[:company_name] if options[:company_name]
535+
doc[fetch_version].title options[:title] if options[:title]
534536

535537
if (billing_address = options[:billing_address])
536538
if billing_address[:phone]
537-
doc['v1'].phone do
538-
doc['v1'].type(options[:phone_number_type] || '4')
539-
doc['v1'].nr billing_address[:phone].gsub(/\D/, '')
539+
doc[fetch_version].phone do
540+
doc[fetch_version].type(options[:phone_number_type] || '4')
541+
doc[fetch_version].nr billing_address[:phone].gsub(/\D/, '')
540542
end
541543
end
542-
doc['v1'].addrLn1 billing_address[:address1] if billing_address[:address1]
543-
doc['v1'].addrLn2 billing_address[:address2] unless billing_address[:address2].blank?
544-
doc['v1'].city billing_address[:city] if billing_address[:city]
545-
doc['v1'].state billing_address[:state] if billing_address[:state]
546-
doc['v1'].zipCode billing_address[:zip].delete('-') if billing_address[:zip]
547-
doc['v1'].ctry 'US'
544+
doc[fetch_version].addrLn1 billing_address[:address1] if billing_address[:address1]
545+
doc[fetch_version].addrLn2 billing_address[:address2] unless billing_address[:address2].blank?
546+
doc[fetch_version].city billing_address[:city] if billing_address[:city]
547+
doc[fetch_version].state billing_address[:state] if billing_address[:state]
548+
doc[fetch_version].zipCode billing_address[:zip].delete('-') if billing_address[:zip]
549+
doc[fetch_version].ctry 'US'
548550
end
549551

550-
doc['v1'].email options[:email] if options[:email]
551-
doc['v1'].type options[:contact_type] if options[:contact_type]
552-
doc['v1'].stat options[:contact_stat] if options[:contact_stat]
552+
doc[fetch_version].email options[:email] if options[:email]
553+
doc[fetch_version].type options[:contact_type] if options[:contact_type]
554+
doc[fetch_version].stat options[:contact_stat] if options[:contact_stat]
553555

554556
if (shipping_address = options[:shipping_address])
555-
doc['v1'].ship do
556-
doc['v1'].fullName fullname unless fullname.blank?
557-
doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1]
558-
doc['v1'].addrLn2 shipping_address[:address2] unless shipping_address[:address2].blank?
559-
doc['v1'].city shipping_address[:city] if shipping_address[:city]
560-
doc['v1'].state shipping_address[:state] if shipping_address[:state]
561-
doc['v1'].zipCode shipping_address[:zip].delete('-') if shipping_address[:zip]
562-
doc['v1'].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone]
563-
doc['v1'].email shipping_address[:email] if shipping_address[:email]
557+
doc[fetch_version].ship do
558+
doc[fetch_version].fullName fullname unless fullname.blank?
559+
doc[fetch_version].addrLn1 shipping_address[:address1] if shipping_address[:address1]
560+
doc[fetch_version].addrLn2 shipping_address[:address2] unless shipping_address[:address2].blank?
561+
doc[fetch_version].city shipping_address[:city] if shipping_address[:city]
562+
doc[fetch_version].state shipping_address[:state] if shipping_address[:state]
563+
doc[fetch_version].zipCode shipping_address[:zip].delete('-') if shipping_address[:zip]
564+
doc[fetch_version].phone shipping_address[:phone].gsub(/\D/, '') if shipping_address[:phone]
565+
doc[fetch_version].email shipping_address[:email] if shipping_address[:email]
564566
end
565567
end
566568
end
567569
end
568570

569571
def add_name(doc, payment_method)
570-
doc['v1'].contact do
571-
doc['v1'].fullName payment_method.name unless payment_method.name.blank?
572+
doc[fetch_version].contact do
573+
doc[fetch_version].fullName payment_method.name unless payment_method.name.blank?
572574
end
573575
end
574576

575577
def add_original_transaction_data(doc, authorization)
576-
doc['v1'].origTranData do
577-
doc['v1'].tranNr authorization
578+
doc[fetch_version].origTranData do
579+
doc[fetch_version].tranNr authorization
578580
end
579581
end
580582

581583
def store_customer_details(doc, fullname, options)
582584
options[:contact_type] = 1 # recurring
583585
options[:contact_stat] = 1 # active
584586

585-
doc['v1'].cust do
586-
doc['v1'].type 0 # add
587+
doc[fetch_version].cust do
588+
doc[fetch_version].type 0 # add
587589
add_contact(doc, fullname, options)
588590
end
589591
end
590592

591593
def add_customer_id(doc, customer_id)
592-
doc['v1'].contact do
593-
doc['v1'].id customer_id
594+
doc[fetch_version].contact do
595+
doc[fetch_version].id customer_id
594596
end
595597
end
596598

597599
def add_wallet_id(doc, wallet_id)
598-
doc['v1'].recurMan do
599-
doc['v1'].id wallet_id
600+
doc[fetch_version].recurMan do
601+
doc[fetch_version].id wallet_id
600602
end
601603
end
602604
end

lib/active_merchant/billing/gateways/usa_epay_advanced.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ module Billing # :nodoc:
6262
# * {USA ePay Developer Login}[https://www.usaepay.com/developer/login]
6363
#
6464
class UsaEpayAdvancedGateway < Gateway
65-
API_VERSION = '1.4'
65+
version '1.4'
6666

6767
TEST_URL_BASE = 'https://sandbox.usaepay.com/soap/gate/' # :nodoc:
6868
LIVE_URL_BASE = 'https://www.usaepay.com/soap/gate/' # :nodoc:

test/unit/gateways/tns_test.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ def setup
1818
}
1919
end
2020

21+
def test_api_version
22+
assert_equal '52', @gateway.fetch_version
23+
end
24+
2125
def test_successful_purchase
2226
@gateway.expects(:ssl_request).twice.returns(successful_authorize_response).then.returns(successful_capture_response)
2327

@@ -178,6 +182,13 @@ def test_scrub
178182
assert_equal @gateway.scrub(pre_scrubbed), post_scrubbed
179183
end
180184

185+
def test_url
186+
assert_equal 'https://secure.na.tnspayments.com/api/rest/version/52/', @gateway.live_na_url
187+
assert_equal 'https://secure.ap.tnspayments.com/api/rest/version/52/', @gateway.live_ap_url
188+
assert_equal 'https://secure.eu.tnspayments.com/api/rest/version/52/', @gateway.live_eu_url
189+
assert_equal 'https://secure.uat.tnspayments.com/api/rest/version/52/', @gateway.test_url
190+
end
191+
181192
private
182193

183194
def pre_scrubbed

test/unit/gateways/trans_first_transaction_express_test.rb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ def setup
1515
@declined_amount = 21
1616
end
1717

18+
def test_api_version
19+
assert_equal 'v1', @gateway.fetch_version
20+
end
21+
1822
def test_successful_purchase
1923
response = stub_comms do
2024
@gateway.purchase(@amount, @credit_card)
@@ -274,6 +278,11 @@ def test_account_number_scrubbing
274278
assert_equal post_scrubbed_account_number, @gateway.scrub(pre_scrubbed_account_number)
275279
end
276280

281+
def test_url
282+
assert_equal 'https://ws.cert.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl', @gateway.test_url
283+
assert_equal 'https://ws.transactionexpress.com/portal/merchantframework/MerchantWebServices-v1?wsdl', @gateway.live_url
284+
end
285+
277286
private
278287

279288
def successful_purchase_response

test/unit/gateways/usa_epay_advanced_test.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,10 @@ def setup
103103

104104
# Standard Gateway ==================================================
105105

106+
def test_api_version
107+
assert_equal '1.4', @gateway.fetch_version
108+
end
109+
106110
def test_successful_purchase
107111
@gateway.expects(:ssl_post).returns(successful_purchase_response)
108112
assert response = @gateway.purchase(1234, @credit_card, @options)

0 commit comments

Comments
 (0)