diff --git a/CHANGELOG b/CHANGELOG index 04ff67fd002..0d8428bf14e 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ * Cybersource: Send tokenization data when card is :master [pi3r] #3230 * Bluesnap: Omit state codes for unsupported countries [therufs] #3229 * Adyen: Pass updateShopperStatement, industryUsage [curiousepic] #3233 +* TransFirst Transaction Express: Fix blank address2 values [britth] #3231 == Version 1.94.0 (May 21, 2019) * Mundipagg: Fix number lengths for both VR and Sodexo [dtykocki] #3195 diff --git a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb index fe94ffe357b..f35fe0d9b78 100644 --- a/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +++ b/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb @@ -544,7 +544,7 @@ def add_contact(doc, fullname, options) end end doc['v1'].addrLn1 billing_address[:address1] if billing_address[:address1] - doc['v1'].addrLn2 billing_address[:address2] if billing_address[:address2] + doc['v1'].addrLn2 billing_address[:address2] unless billing_address[:address2].blank? doc['v1'].city billing_address[:city] if billing_address[:city] doc['v1'].state billing_address[:state] if billing_address[:state] doc['v1'].zipCode billing_address[:zip] if billing_address[:zip] @@ -559,7 +559,7 @@ def add_contact(doc, fullname, options) doc['v1'].ship do doc['v1'].fullName fullname unless fullname.blank? doc['v1'].addrLn1 shipping_address[:address1] if shipping_address[:address1] - doc['v1'].addrLn2 shipping_address[:address2] if shipping_address[:address2] + doc['v1'].addrLn2 shipping_address[:address2] unless shipping_address[:address2].blank? doc['v1'].city shipping_address[:city] if shipping_address[:city] doc['v1'].state shipping_address[:state] if shipping_address[:state] doc['v1'].zipCode shipping_address[:zip] if shipping_address[:zip] diff --git a/test/remote/gateways/remote_trans_first_transaction_express_test.rb b/test/remote/gateways/remote_trans_first_transaction_express_test.rb index 9a97eee54f0..3e69c82ecee 100644 --- a/test/remote/gateways/remote_trans_first_transaction_express_test.rb +++ b/test/remote/gateways/remote_trans_first_transaction_express_test.rb @@ -7,7 +7,7 @@ def setup @amount = 100 @declined_amount = 21 - @credit_card = credit_card('4485896261017708') + @credit_card = credit_card('4485896261017708', verification_value: 999) @check = check billing_address = address({ @@ -76,6 +76,26 @@ def test_successful_purchase_with_only_required assert_equal 'CVV matches', response.cvv_result['message'] end + def test_successful_purchase_without_address2 + # Test that empty string in `address2` doesn't cause transaction failure + options = @options.dup + options[:shipping_address] = { + address1: '450 Main', + address2: '', + zip: '85284', + } + + options[:billing_address] = { + address1: '450 Main', + address2: '', + zip: '85284', + } + + response = @gateway.purchase(@amount, @credit_card, options) + assert_success response + assert_equal 'Succeeded', response.message + end + def test_successful_purchase_without_cvv credit_card_opts = { :number => 4485896261017708,