Skip to content

Commit

Permalink
Nuvei: Add GSF for verify method
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Javier Pedroza committed Sep 27, 2024
1 parent 8575398 commit be454c5
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/nuvei.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions test/remote/gateways/remote_nuvei_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 14 additions & 0 deletions test/unit/gateways/nuvei_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit be454c5

Please sign in to comment.