Skip to content

Commit

Permalink
Element: fix bug with billing address email
Browse files Browse the repository at this point in the history
Enables the `add_address` method to successfully find `email` whether it is nested at the top level of the `options` hash or within the `billing_address` object

CER-330
  • Loading branch information
jcreiff committed Dec 9, 2022
1 parent 64427ce commit 8214fb8
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions test/remote/gateways/remote_element_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]'))
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
Expand Down
10 changes: 10 additions & 0 deletions test/unit/gateways/element_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: '[email protected]'))
end.check_request do |_endpoint, data, _headers|
assert_match '<BillingEmail>[email protected]</BillingEmail>', 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
Expand Down

0 comments on commit 8214fb8

Please sign in to comment.