Skip to content

Commit

Permalink
DLocal: update the zip and ip fields
Browse files Browse the repository at this point in the history
  • Loading branch information
yunnydang committed Jun 12, 2024
1 parent 32e4da3 commit 23169a5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/active_merchant/billing/gateways/d_local.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 6 additions & 0 deletions test/remote/gateways/remote_d_local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 9 additions & 0 deletions test/unit/gateways/d_local_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 23169a5

Please sign in to comment.