Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PayJunctionv2: Fix billing address fields #3557

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* Adyen: Add tests for voiding with idempotency keys [jknipp] #3553
* Fat Zebra: Fix `store` call [chinhle23] #3556
* Update README to include Adyen [haolime] #3452
* PayJunctionv2: Fix billing address fields [leila-alderman] #3557

== Version 1.105.0 (Feb 20, 2020)
* Credorax: Fix `3ds_transtype` setting in post [chinhle23] #3531
Expand Down
23 changes: 10 additions & 13 deletions lib/active_merchant/billing/gateways/pay_junction_v2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -113,19 +113,16 @@ def add_payment_method(post, payment_method)
end

def add_address(post, options)
if (address = options[:billing_address])
post[:billing] = {}
post[:billing][:firstName] = address[:first_name] if address[:first_name]
post[:billing][:lastName] = address[:last_name] if address[:last_name]
post[:billing][:companyName] = address[:company] if address[:company]
post[:billing][:phone] = address[:phone_number] if address[:phone_number]

post[:billing][:address] = {}
post[:billing][:address][:address] = address[:address1] if address[:address1]
post[:billing][:address][:city] = address[:city] if address[:city]
post[:billing][:address][:state] = address[:state] if address[:state]
post[:billing][:address][:country] = address[:country] if address[:country]
post[:billing][:address][:zip] = address[:zip] if address[:zip]
if address = options[:billing_address]
post[:billingFirstName] = address[:first_name] if address[:first_name]
post[:billingLastName] = address[:last_name] if address[:last_name]
post[:billingCompanyName] = address[:company] if address[:company]
post[:billingPhone] = address[:phone_number] if address[:phone_number]
post[:billingAddress] = address[:address1] if address[:address1]
post[:billingCity] = address[:city] if address[:city]
post[:billingState] = address[:state] if address[:state]
post[:billingCountry] = address[:country] if address[:country]
post[:billingZip] = address[:zip] if address[:zip]
end
end

Expand Down
7 changes: 7 additions & 0 deletions test/remote/gateways/remote_pay_junction_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ def test_successful_purchase
assert_success response
assert_equal 'Approved', response.message
assert response.test?

assert_match @options[:billing_address][:company], response.params['billing']['companyName']
assert_match @options[:billing_address][:address1], response.params['billing']['address']['address']
assert_match @options[:billing_address][:city], response.params['billing']['address']['city']
assert_match @options[:billing_address][:state], response.params['billing']['address']['state']
assert_match @options[:billing_address][:country], response.params['billing']['address']['country']
assert_match @options[:billing_address][:zip], response.params['billing']['address']['zip']
end

def test_successful_purchase_sans_options
Expand Down
19 changes: 9 additions & 10 deletions test/unit/gateways/pay_junction_v2_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -209,16 +209,15 @@ def test_failed_store
def test_add_address
post = {card: {billingAddress: {}}}
@gateway.send(:add_address, post, @options)
# Billing Address
assert_equal @options[:billing_address][:first_name], post[:billing][:firstName]
assert_equal @options[:billing_address][:last_name], post[:billing][:lastName]
assert_equal @options[:billing_address][:company], post[:billing][:companyName]
assert_equal @options[:billing_address][:phone_number], post[:billing][:phone]
assert_equal @options[:billing_address][:address1], post[:billing][:address][:address]
assert_equal @options[:billing_address][:city], post[:billing][:address][:city]
assert_equal @options[:billing_address][:state], post[:billing][:address][:state]
assert_equal @options[:billing_address][:country], post[:billing][:address][:country]
assert_equal @options[:billing_address][:zip], post[:billing][:address][:zip]
assert_equal @options[:billing_address][:first_name], post[:billingFirstName]
assert_equal @options[:billing_address][:last_name], post[:billingLastName]
assert_equal @options[:billing_address][:company], post[:billingCompanyName]
assert_equal @options[:billing_address][:phone_number], post[:billingPhone]
assert_equal @options[:billing_address][:address1], post[:billingAddress]
assert_equal @options[:billing_address][:city], post[:billingCity]
assert_equal @options[:billing_address][:state], post[:billingState]
assert_equal @options[:billing_address][:country], post[:billingCountry]
assert_equal @options[:billing_address][:zip], post[:billingZip]
end

def test_scrub
Expand Down