diff --git a/CHANGELOG b/CHANGELOG index 561c9aa1291..17fcc564a0a 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ * RuboCop: Fix Layout/EndAlignment [leila-alderman] #3427 * RuboCop: Fix Layout/ExtraSpacing [leila-alderman] #3429 * RuboCop: Fix Layout/MultilineOperationIndentation [leila-alderman] #3439 +* Worldpay: Update logic to set cardholderName for 3DS transactions [britth] #3444 == Version 1.101.0 (Nov 4, 2019) * Add UYI to list of currencies without fractions [curiousepic] #3416 diff --git a/lib/active_merchant/billing/gateways/worldpay.rb b/lib/active_merchant/billing/gateways/worldpay.rb index 27bef9a8634..805fa0ca6d1 100644 --- a/lib/active_merchant/billing/gateways/worldpay.rb +++ b/lib/active_merchant/billing/gateways/worldpay.rb @@ -335,7 +335,7 @@ def add_card(xml, payment_method, options) xml.tag! 'date', 'month' => format(payment_method.month, :two_digits), 'year' => format(payment_method.year, :four_digits) end - xml.tag! 'cardHolderName', options[:execute_threed] && (options[:three_ds_version] =~ /[^2]/).nil? ? '3D' : payment_method.name + xml.tag! 'cardHolderName', options[:execute_threed] && !options[:three_ds_version]&.start_with?('2') ? '3D' : payment_method.name xml.tag! 'cvc', payment_method.verification_value add_address(xml, (options[:billing_address] || options[:address])) diff --git a/test/unit/gateways/worldpay_test.rb b/test/unit/gateways/worldpay_test.rb index 679af17ed49..03f0843a124 100644 --- a/test/unit/gateways/worldpay_test.rb +++ b/test/unit/gateways/worldpay_test.rb @@ -606,6 +606,39 @@ def test_3ds_name_coersion assert_success response end + def test_3ds_name_coersion_based_on_version + @options[:execute_threed] = true + @options[:three_ds_version] = '2.0' + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + if // =~ data + assert_match %r{Longbob Longsen}, data + end + end.respond_with(successful_authorize_response, successful_capture_response) + assert_success response + + @options[:three_ds_version] = '2' + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + if // =~ data + assert_match %r{Longbob Longsen}, data + end + end.respond_with(successful_authorize_response, successful_capture_response) + assert_success response + + @options[:three_ds_version] = '1.0.2' + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options) + end.check_request do |endpoint, data, headers| + if // =~ data + assert_match %r{3D}, data + end + end.respond_with(successful_authorize_response, successful_capture_response) + assert_success response + end + def test_transcript_scrubbing assert_equal scrubbed_transcript, @gateway.scrub(transcript) end