diff --git a/CHANGELOG b/CHANGELOG index 24ce5495e1b..9cc762e3263 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -99,7 +99,6 @@ * FlexCharge: Update homePage url [javierpedrozaing] #5351 * Nuvei: Fix send savePM in false by default [javierpedrozaing] #5353 * Decidir and DecicirPlus: Add the wallet_id field [yunnydang] #5354 -* Worldpay: Idempotency key fix [jherreraa] #5343 == 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/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 67ea78c7f0b..52b629ebc28 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -954,12 +954,7 @@ def headers(options) cookie = options[:cookie] || cookie headers['Cookie'] = cookie if cookie - # Required because Worldpay does not accept duplicate idempotency keys - # for different transactions, such as in the case of an authorize => capture flow. - if idempotency_key - headers['Idempotency-Key'] = idempotency_key - options[:idempotency_key] = SecureRandom.uuid - end + headers['Idempotency-Key'] = idempotency_key if idempotency_key headers end diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 5cdacb7d3fb..3296e33785c 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -306,8 +306,8 @@ def test_unsucessfull_authorize_without_token_number_apple_pay response = @gateway.authorize(@amount, @apple_pay_network_token, @options) assert_failure response - assert_equal response.error_code, '2' - assert_match "Missing required elements 'tokenNumber'", response.message + assert_equal response.error_code, '5' + assert_equal "Element 'tokenNumber' must have valid numeric content.", response.message end def test_unsucessfull_authorize_with_token_number_as_empty_string_apple_pay @@ -315,8 +315,8 @@ def test_unsucessfull_authorize_with_token_number_as_empty_string_apple_pay response = @gateway.authorize(@amount, @apple_pay_network_token, @options) assert_failure response - assert_equal response.error_code, '2' - assert_match "Missing required elements 'tokenNumber'", response.message + assert_equal response.error_code, '5' + assert_equal "Element 'tokenNumber' must have valid numeric content.", response.message end def test_unsucessfull_authorize_with_invalid_token_number_apple_pay @@ -1342,7 +1342,7 @@ def test_failed_refund_synchronous_response refund = @cftgateway.refund(@amount * 2, auth.authorization, authorization_validated: true) assert_failure refund - assert_equal 'Invalid amount: The refund amount should be equal to the captured value', refund.message + assert_equal 'Refund amount too high', refund.message end def test_successful_purchase_with_options_synchronous_response diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 3d70eacf27c..8f173ec9409 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -223,12 +223,6 @@ def test_payment_type_for_credit_card assert_equal payment, :credit end - def test_idempotency_header - options = { idempotency_key: 'test123' } - headers = @gateway.send(:headers, options) - assert_not_equal options[:idempotency_key], headers['Idempotency-Key'] - end - def test_successful_authorize response = stub_comms do @gateway.authorize(@amount, @credit_card, @options)