Skip to content

Commit

Permalink
Adyen: Handles blank state address field
Browse files Browse the repository at this point in the history
Sends N/A if state field is not populated. Resolves validation errors from sending blank state field.

ECS-102

Remote:
39 tests, 100 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed

Unit:
26 tests, 127 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
molbrown committed Jan 15, 2019
1 parent 364d621 commit a290873
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
* Improved support for account_type using Check class's account_type instead [lancecarlson] #3097
* USA Epay: Allow quantity to be passed and check custom fields [lancecarlson] #3090
* Fix usaepay transaction invoice [lancecarlson] #3093
* Adyen: Handles blank state address field [molbrown] #3113

== Version 1.90.0 (January 8, 2019)
* Mercado Pago: Support "gateway" processing mode [curiousepic] #3087
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/adyen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ def add_address(post, options)
post[:card][:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
post[:card][:billingAddress][:postalCode] = address[:zip] if address[:zip]
post[:card][:billingAddress][:city] = address[:city] || 'N/A'
post[:card][:billingAddress][:stateOrProvince] = address[:state] if address[:state]
post[:card][:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
post[:card][:billingAddress][:country] = address[:country] if address[:country]
end
end
Expand Down
6 changes: 6 additions & 0 deletions test/remote/gateways/remote_adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,12 @@ def test_missing_house_number_or_name_for_purchase
assert_success response
end

def test_missing_state_for_purchase
@options[:billing_address].delete(:state)
response = @gateway.authorize(@amount, @credit_card, @options)
assert_success response
end

def test_invalid_country_for_purchase
@options[:billing_address][:country] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
Expand Down
3 changes: 2 additions & 1 deletion test/unit/gateways/adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,13 @@ def test_add_address
post = {:card => {:billingAddress => {}}}
@options[:billing_address].delete(:address1)
@options[:billing_address].delete(:address2)
@options[:billing_address].delete(:state)
@gateway.send(:add_address, post, @options)
assert_equal 'N/A', post[:card][:billingAddress][:street]
assert_equal 'N/A', post[:card][:billingAddress][:houseNumberOrName]
assert_equal 'N/A', post[:card][:billingAddress][:stateOrProvince]
assert_equal @options[:billing_address][:zip], post[:card][:billingAddress][:postalCode]
assert_equal @options[:billing_address][:city], post[:card][:billingAddress][:city]
assert_equal @options[:billing_address][:state], post[:card][:billingAddress][:stateOrProvince]
assert_equal @options[:billing_address][:country], post[:card][:billingAddress][:country]
end

Expand Down

0 comments on commit a290873

Please sign in to comment.