From 89ddf5322565d8bd7530b547c2f6cf3633b22f5d Mon Sep 17 00:00:00 2001 From: Alma Malambo Date: Thu, 1 Aug 2024 15:35:52 -0500 Subject: [PATCH] Iveri: Add AuthReversal for Authorizations If the transaction to be voided is an Authorization then use AuthReversal instead of Void. Remote 22 tests, 56 assertions, 1 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 95.4545% passed Unit 16 tests, 67 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/iveri.rb | 5 +++-- test/remote/gateways/remote_iveri_test.rb | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 0634a804b2a..9e11baee976 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -16,6 +16,7 @@ * Decidir: Pass CVV for NT [almalee24] #5205 * NMI: Add customer vault fields [yunnydang] #5215 * CheckoutV2: Add inquire method [almalee24] #5209 +* Iveri: Add AuthReversal for Authorizations [almalee24] #5201 == Version 1.137.0 (August 2, 2024) * Unlock dependency on `rexml` to allow fixing a CVE (#5181). diff --git a/lib/active_merchant/billing/gateways/iveri.rb b/lib/active_merchant/billing/gateways/iveri.rb index c2cb8aa141a..2fa669c21cc 100644 --- a/lib/active_merchant/billing/gateways/iveri.rb +++ b/lib/active_merchant/billing/gateways/iveri.rb @@ -55,7 +55,8 @@ def refund(money, authorization, options = {}) end def void(authorization, options = {}) - post = build_vxml_request('Void', options) do |xml| + txn_type = options[:reference_type] == :authorize ? 'AuthReversal' : 'Void' + post = build_vxml_request(txn_type, options) do |xml| add_authorization(xml, authorization, options) end @@ -65,7 +66,7 @@ def void(authorization, options = {}) def verify(credit_card, options = {}) MultiResponse.run(:use_first_response) do |r| r.process { authorize(100, credit_card, options) } - r.process(:ignore_result) { void(r.authorization, options) } + r.process(:ignore_result) { void(r.authorization, options.merge(reference_type: :authorize)) } end end diff --git a/test/remote/gateways/remote_iveri_test.rb b/test/remote/gateways/remote_iveri_test.rb index 0ced8b40be3..5933fa60275 100644 --- a/test/remote/gateways/remote_iveri_test.rb +++ b/test/remote/gateways/remote_iveri_test.rb @@ -136,8 +136,8 @@ def test_successful_verify assert_success response assert_equal 'Authorisation', response.responses[0].params['transaction_command'] assert_equal '0', response.responses[0].params['result_status'] - assert_equal 'Void', response.responses[1].params['transaction_command'] - assert_equal '0', response.responses[1].params['result_status'] + assert_equal 'AuthReversal', response.responses[1].params['transaction_command'] + assert_equal '-1', response.responses[1].params['result_status'] assert_equal 'Succeeded', response.message end