diff --git a/CHANGELOG b/CHANGELOG index 4085d2027e4..b52f88f22c6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 diff --git a/lib/active_merchant/billing/gateways/pay_junction_v2.rb b/lib/active_merchant/billing/gateways/pay_junction_v2.rb index 06a12466307..6235a99e6b7 100644 --- a/lib/active_merchant/billing/gateways/pay_junction_v2.rb +++ b/lib/active_merchant/billing/gateways/pay_junction_v2.rb @@ -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 diff --git a/test/remote/gateways/remote_pay_junction_v2_test.rb b/test/remote/gateways/remote_pay_junction_v2_test.rb index 0fb01609685..8d6ae6987bf 100644 --- a/test/remote/gateways/remote_pay_junction_v2_test.rb +++ b/test/remote/gateways/remote_pay_junction_v2_test.rb @@ -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 diff --git a/test/unit/gateways/pay_junction_v2_test.rb b/test/unit/gateways/pay_junction_v2_test.rb index 39a87c59bc1..0fa000c8984 100644 --- a/test/unit/gateways/pay_junction_v2_test.rb +++ b/test/unit/gateways/pay_junction_v2_test.rb @@ -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