From 08434722781ae51580d1eaf23556d0a480be35a6 Mon Sep 17 00:00:00 2001 From: Pierre Nespo Date: Mon, 2 Dec 2019 07:33:26 -0500 Subject: [PATCH] Use null@cybersource.com when option[:email] is an empty string (#3462) 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 null@cybersource.com for both `nil` and `""`. --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/cyber_source.rb | 2 +- test/unit/gateways/cyber_source_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 11f327a0c22..71913ed2114 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -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 null@cybersource.com 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 diff --git a/lib/active_merchant/billing/gateways/cyber_source.rb b/lib/active_merchant/billing/gateways/cyber_source.rb index b0f98f0bdb1..8d3d8d5958e 100644 --- a/lib/active_merchant/billing/gateways/cyber_source.rb +++ b/lib/active_merchant/billing/gateways/cyber_source.rb @@ -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] || 'null@cybersource.com' + xml.tag! 'email', options[:email].presence || 'null@cybersource.com' 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? diff --git a/test/unit/gateways/cyber_source_test.rb b/test/unit/gateways/cyber_source_test.rb index e3a1214c7cd..3107eff7679 100644 --- a/test/unit/gateways/cyber_source_test.rb +++ b/test/unit/gateways/cyber_source_test.rb @@ -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('null@cybersource.com', data) + end.respond_with(successful_capture_response) + end + private def pre_scrubbed