diff --git a/CHANGELOG b/CHANGELOG index 3b87c9d1849..21fc5d29e4c 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -37,6 +37,7 @@ * Mundipagg: send authorization_secret_key on all transaction types [edgarv09] #4635 * CommerceHub: Add new gateway [naashton] #4640 * CyberSource: Update installment data method [rachelkirk] #4642 +* Element: fix bug with billing address email [jcreiff] #4644 == Version 1.127.0 (September 20th, 2022) * BraintreeBlue: Add venmo profile_id [molbrown] #4512 diff --git a/lib/active_merchant/billing/gateways/element.rb b/lib/active_merchant/billing/gateways/element.rb index 527a6306d7d..ded922a3c3f 100644 --- a/lib/active_merchant/billing/gateways/element.rb +++ b/lib/active_merchant/billing/gateways/element.rb @@ -248,6 +248,7 @@ def add_echeck(xml, payment) def add_address(xml, options) if address = options[:billing_address] || options[:address] + address[:email] ||= options[:email] xml.address do xml.BillingAddress1 address[:address1] if address[:address1] xml.BillingAddress2 address[:address2] if address[:address2] diff --git a/test/remote/gateways/remote_element_test.rb b/test/remote/gateways/remote_element_test.rb index 93a0911de77..633762c732d 100644 --- a/test/remote/gateways/remote_element_test.rb +++ b/test/remote/gateways/remote_element_test.rb @@ -50,6 +50,12 @@ def test_successful_purchase_with_shipping_address assert_equal 'Approved', response.message end + def test_successful_purchase_with_billing_email + response = @gateway.purchase(@amount, @credit_card, @options.merge(email: 'test@example.com')) + assert_success response + assert_equal 'Approved', response.message + end + def test_successful_purchase_with_card_present_code response = @gateway.purchase(@amount, @credit_card, @options.merge(card_present_code: 'Present')) assert_success response diff --git a/test/unit/gateways/element_test.rb b/test/unit/gateways/element_test.rb index 0c273addd1a..ece96d068e5 100644 --- a/test/unit/gateways/element_test.rb +++ b/test/unit/gateways/element_test.rb @@ -296,6 +296,16 @@ def test_successful_purchase_with_merchant_descriptor assert_success response end + def test_successful_purchase_with_billing_email + response = stub_comms do + @gateway.purchase(@amount, @credit_card, @options.merge(email: 'test@example.com')) + end.check_request do |_endpoint, data, _headers| + assert_match 'test@example.com', data + end.respond_with(successful_purchase_response) + + assert_success response + end + def test_successful_credit_with_extra_fields credit_options = @options.merge({ ticket_number: '1', market_code: 'FoodRestaurant', merchant_supplied_transaction_id: '123' }) stub_comms do