Skip to content

Commit

Permalink
Use [email protected] when option[:email] is an empty string (#3462)
Browse files Browse the repository at this point in the history
We've had some cases where email ends up being sent as an empty string
and the current logic only checks for it's existence, not for its value.
We should use [email protected] for both `nil` and `""`.
  • Loading branch information
Pierre Nespo authored Dec 2, 2019
1 parent 0ba8ab7 commit 0843472
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
* Adyen: Add gateway specific field for splits [leila-alderman] #3448
* Adyen: Add `unstore` and `storeToken` actions with '/Recurring' endpoint [deedeelavinder][davidsantoso] #3438
* Barclaycard Smartpay: Add functionality to set 3DS exemptions via API [britth] #3457
* Use [email protected] when option[:email] is an empty string [pi3r] #3462

== Version 1.102.0 (Nov 14, 2019)
* Quickbooks: Make token refresh optional with allow_refresh flag [britth] #3419
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/cyber_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ def add_address(xml, payment_method, address, options, shipTo = false)
xml.tag! 'company', address[:company] unless address[:company].blank?
xml.tag! 'companyTaxID', address[:companyTaxID] unless address[:company_tax_id].blank?
xml.tag! 'phoneNumber', address[:phone] unless address[:phone].blank?
xml.tag! 'email', options[:email] || '[email protected]'
xml.tag! 'email', options[:email].presence || '[email protected]'
xml.tag! 'ipAddress', options[:ip] unless options[:ip].blank? || shipTo
xml.tag! 'driversLicenseNumber', options[:drivers_license_number] unless options[:drivers_license_number].blank?
xml.tag! 'driversLicenseState', options[:drivers_license_state] unless options[:drivers_license_state].blank?
Expand Down
8 changes: 8 additions & 0 deletions test/unit/gateways/cyber_source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -717,6 +717,14 @@ def test_does_not_throw_on_invalid_xml
assert_failure response
end

def test_address_email_has_a_default_when_email_option_is_empty
stub_comms do
@gateway.authorize(100, @credit_card, email: '')
end.check_request do |endpoint, data, headers|
assert_match('<email>[email protected]</email>', data)
end.respond_with(successful_capture_response)
end

private

def pre_scrubbed
Expand Down

0 comments on commit 0843472

Please sign in to comment.