diff --git a/CHANGELOG b/CHANGELOG index 24ce5495e1b..88cb0b6bc99 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -100,6 +100,7 @@ * 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 +* Worldpay: Update where to pass shopperIPAddress [almalee24] #5348 == 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..24d7a8fc24c 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -402,7 +402,12 @@ def build_fast_fund_credit_request(money, payment_method, options) add_amount(xml, money, options) add_order_content(xml, options) add_payment_details_for_ff_credit(xml, payment_method, options) - add_shopper_id(xml, options) + + if options[:email] + xml.shopper do + xml.shopperEmailAddress options[:email] + end + end end end end @@ -477,6 +482,7 @@ def add_payment_details_for_ff_credit(xml, payment_method, options) add_token_for_ff_credit(xml, payment_method, options) end end + add_shopper_id(xml, options) end end @@ -670,8 +676,8 @@ def add_network_tokenization_card(xml, payment_method, options) eci = eci_value(payment_method, options) xml.eciIndicator eci if eci.present? end - add_shopper_id(xml, options, false) add_stored_credential_options(xml, options) + add_shopper_id(xml, options, false) end end diff --git a/test/remote/gateways/remote_worldpay_test.rb b/test/remote/gateways/remote_worldpay_test.rb index 5cdacb7d3fb..8b00685ef77 100644 --- a/test/remote/gateways/remote_worldpay_test.rb +++ b/test/remote/gateways/remote_worldpay_test.rb @@ -51,7 +51,8 @@ def setup @options = { order_id: generate_unique_id, - email: 'wow@example.com' + email: 'wow@example.com', + ip: '127.0.0.1' } @level_two_data = { @@ -1037,35 +1038,32 @@ def test_failed_visa_account_funding_transfer_acquirer_error assert_equal '20', credit.error_code end - # These three fast_fund_credit tests are currently failing with the message: Disbursement transaction not supported - # It seems that the current sandbox setup does not support testing this. - - # def test_successful_fast_fund_credit_on_cft_gateway - # options = @options.merge({ fast_fund_credit: true }) + def test_successful_fast_fund_credit_on_cft_gateway + options = @options.merge({ fast_fund_credit: true }) - # credit = @cftgateway.credit(@amount, @credit_card, options) - # assert_success credit - # assert_equal 'SUCCESS', credit.message - # end + credit = @cftgateway.credit(@amount, @credit_card, options) + assert_success credit + assert_equal 'SUCCESS', credit.message + end - # def test_successful_fast_fund_credit_with_token_on_cft_gateway - # assert store = @gateway.store(@credit_card, @store_options) - # assert_success store + def test_successful_fast_fund_credit_with_token_on_cft_gateway + assert store = @gateway.store(@credit_card, @store_options) + assert_success store - # options = @options.merge({ fast_fund_credit: true }) - # assert credit = @cftgateway.credit(@amount, store.authorization, options) - # assert_success credit - # end + options = @options.merge({ fast_fund_credit: true }) + assert credit = @cftgateway.credit(@amount, store.authorization, options) + assert_success credit + end - # def test_failed_fast_fund_credit_on_cft_gateway - # options = @options.merge({ fast_fund_credit: true }) - # refused_card = credit_card('4444333322221111', name: 'REFUSED') # 'magic' value for testing failures, provided by Worldpay + def test_failed_fast_fund_credit_on_cft_gateway + options = @options.merge({ fast_fund_credit: true }) + refused_card = credit_card('4444333322221111', name: 'REFUSED') # 'magic' value for testing failures, provided by Worldpay - # credit = @cftgateway.credit(@amount, refused_card, options) - # assert_failure credit - # assert_equal '01', credit.params['action_code'] - # assert_equal "A transaction status of 'ok' or 'PUSH_APPROVED' is required.", credit.message - # end + credit = @cftgateway.credit(@amount, refused_card, options) + assert_failure credit + assert_equal '01', credit.params['action_code'] + assert_equal "A transaction status of 'ok' or 'PUSH_APPROVED' is required.", credit.message + end def test_transcript_scrubbing transcript = capture_transcript(@gateway) do diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 3d70eacf27c..ce060ec09ae 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -844,6 +844,17 @@ def test_capture_using_order_id_embedded_with_token assert_success response end + def test_successful_fast_fund_credit + options = @options.merge({ fast_fund_credit: true, email: 'test@email.com' }) + + stub_comms do + @gateway.credit(@amount, @credit_card, options) + end.check_request do |_endpoint, data, _headers| + assert_match(//, data) + assert_match(//, data) + end.respond_with(successful_visa_credit_response) + end + def test_successful_visa_credit response = stub_comms do @gateway.credit(@amount, @credit_card, @options)