From be454c5d29489c86fd6fa0b094ad853d55cde3aa Mon Sep 17 00:00:00 2001 From: Javier Pedroza Date: Thu, 26 Sep 2024 17:06:26 -0500 Subject: [PATCH] Nuvei: Add GSF for verify method Description ------------------------- [SER-1462](https://spreedly.atlassian.net/browse/SER-1462) This commit add authenticationOnlyType as GSF for a verify request Unit test ------------------------- Finished in 0.009788 seconds. 18 tests, 99 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 1838.99 tests/s, 10114.43 assertions/s Remote test ------------------------- Finished in 121.496082 seconds. 28 tests, 87 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed 0.23 tests/s, 0.72 assertions/s Rubocop ------------------------- 801 files inspected, no offenses detected --- lib/active_merchant/billing/gateways/nuvei.rb | 2 +- test/remote/gateways/remote_nuvei_test.rb | 6 ++++++ test/unit/gateways/nuvei_test.rb | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/active_merchant/billing/gateways/nuvei.rb b/lib/active_merchant/billing/gateways/nuvei.rb index 471efa4ad56..b433aead3f8 100644 --- a/lib/active_merchant/billing/gateways/nuvei.rb +++ b/lib/active_merchant/billing/gateways/nuvei.rb @@ -38,7 +38,7 @@ def authorize(money, payment, options = {}, transaction_type = 'Auth') add_customer_ip(post, options) add_stored_credentials(post, payment, options) post[:userTokenId] = options[:user_token_id] if options[:user_token_id] - + post[:authenticationOnlyType] = options[:authentication_only_type] if options[:authentication_only_type] if options[:execute_threed] execute_3ds_flow(post, money, payment, transaction_type, options) else diff --git a/test/remote/gateways/remote_nuvei_test.rb b/test/remote/gateways/remote_nuvei_test.rb index 739e32a55e8..221247fa9e5 100644 --- a/test/remote/gateways/remote_nuvei_test.rb +++ b/test/remote/gateways/remote_nuvei_test.rb @@ -191,6 +191,12 @@ def test_successful_verify assert_match 'APPROVED', response.message end + def test_successful_verify_with_authentication_only_type + response = @gateway.verify(@credit_card, @options.merge({ authentication_only_type: 'MAINTAINCARD' })) + assert_match 'SUCCESS', response.params['status'] + assert_match 'APPROVED', response.message + end + def test_successful_general_credit credit_response = @gateway.credit(@amount, @credit_card, @options) assert_success credit_response diff --git a/test/unit/gateways/nuvei_test.rb b/test/unit/gateways/nuvei_test.rb index 30862109d16..28a738981dc 100644 --- a/test/unit/gateways/nuvei_test.rb +++ b/test/unit/gateways/nuvei_test.rb @@ -251,6 +251,20 @@ def test_successful_stored_credentials_merchant_recurring end.respond_with(successful_purchase_response) end + def test_successful_verify + @options.merge!(authentication_only_type: 'ACCOUNTVERIFICATION') + stub_comms(@gateway, :ssl_request) do + @gateway.verify(@credit_card, @options) + end.check_request(skip_response: true) do |_method, endpoint, data, _headers| + if /payment/.match?(endpoint) + json_data = JSON.parse(data) + assert_match(/Auth/, json_data['transactionType']) + assert_match(/ACCOUNTVERIFICATION/, json_data['authenticationOnlyType']) + assert_equal '0', json_data['amount'] + end + end + end + private def three_ds_assertions(payment_option_card)