diff --git a/CHANGELOG b/CHANGELOG index 9438e5336d4..24a5c4c0965 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -9,6 +9,7 @@ * Cybersource Rest: Update support for stored credentials [aenand] #5083 * Plexo: Add support to NetworkToken payments [euribe09] #5130 * Braintree: Update card verfification payload if billing address fields are not present [yunnydang] #5142 +* DLocal: Update the phone and ip fields [yunnydang] #5143 == Version 1.136.0 (June 3, 2024) * Shift4V2: Add new gateway based on SecurionPay adapter [heavyblade] #4860 diff --git a/lib/active_merchant/billing/gateways/d_local.rb b/lib/active_merchant/billing/gateways/d_local.rb index c98d551ceec..9b52fe21488 100644 --- a/lib/active_merchant/billing/gateways/d_local.rb +++ b/lib/active_merchant/billing/gateways/d_local.rb @@ -118,16 +118,18 @@ def lookup_country_code(country_field) def add_payer(post, card, options) address = options[:billing_address] || options[:address] + phone_number = address[:phone] || address[:phone_number] if address + post[:payer] = {} post[:payer][:name] = card.name post[:payer][:email] = options[:email] if options[:email] post[:payer][:birth_date] = options[:birth_date] if options[:birth_date] - post[:payer][:phone] = address[:phone] if address && address[:phone] + post[:payer][:phone] = phone_number if phone_number post[:payer][:document] = options[:document] if options[:document] post[:payer][:document2] = options[:document2] if options[:document2] post[:payer][:user_reference] = options[:user_reference] if options[:user_reference] post[:payer][:event_uuid] = options[:device_id] if options[:device_id] - post[:payer][:onboarding_ip_address] = options[:ip] if options[:ip] + post[:payer][:ip] = options[:ip] if options[:ip] post[:payer][:address] = add_address(post, card, options) end diff --git a/test/remote/gateways/remote_d_local_test.rb b/test/remote/gateways/remote_d_local_test.rb index c46b6aeae6c..7a2ff15f34a 100644 --- a/test/remote/gateways/remote_d_local_test.rb +++ b/test/remote/gateways/remote_d_local_test.rb @@ -50,6 +50,12 @@ def test_successful_purchase assert_match 'The payment was paid', response.message end + def test_successful_purchase_with_ip_and_phone + response = @gateway.purchase(@amount, @credit_card, @options.merge(ip: '127.0.0.1')) + assert_success response + assert_match 'The payment was paid', response.message + end + def test_successful_purchase_with_save_option response = @gateway.purchase(@amount, @credit_card, @options.merge(save: true)) assert_success response diff --git a/test/unit/gateways/d_local_test.rb b/test/unit/gateways/d_local_test.rb index a1bf4c354ff..3d48225d102 100644 --- a/test/unit/gateways/d_local_test.rb +++ b/test/unit/gateways/d_local_test.rb @@ -44,6 +44,15 @@ def test_purchase_with_save end.respond_with(successful_purchase_response) end + def test_purchase_with_ip_and_phone + stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(ip: '127.0.0.1')) + end.check_request do |_endpoint, data, _headers| + assert_equal '127.0.0.1', JSON.parse(data)['payer']['ip'] + assert_equal '(555)555-5555', JSON.parse(data)['payer']['phone'] + end.respond_with(successful_purchase_response) + end + def test_failed_purchase @gateway.expects(:ssl_post).returns(failed_purchase_response)