Skip to content

Commit

Permalink
Nuvei: Add GSF for verify method (#5278)
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

Co-authored-by: Javier Pedroza <[email protected]>
  • Loading branch information
javierpedrozaing and Javier Pedroza authored Oct 18, 2024
1 parent 74848ea commit 4d0d1da
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
* Upgrade rexml to 3.3.8 [raymzag] #5245
* Nuvei: Add partial approval feature [javierpedrozaing] #5250
* Nuvei: Add ACH support [javierpedrozaing] #5269
* Nuvei: Add GSF for verify method [javierpedrozaing] #5278

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
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 @@ -39,7 +39,7 @@ def authorize(money, payment, options = {}, transaction_type = 'Auth')
add_stored_credentials(post, payment, options)
post[:userTokenId] = options[:user_token_id] if options[:user_token_id]
post[:isPartialApproval] = options[:is_partial_approval] ? 1 : 0

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 @@ -193,6 +193,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 @@ -277,6 +277,20 @@ def test_successful_authorize_bank_account
end
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 4d0d1da

Please sign in to comment.