Skip to content

Commit

Permalink
Adyen: Replace empty state string with N/A
Browse files Browse the repository at this point in the history
  • Loading branch information
therufs committed Jul 2, 2019
1 parent 4509244 commit 38327b3
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
6 changes: 5 additions & 1 deletion lib/active_merchant/billing/gateways/adyen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,15 @@ def add_address(post, options)
post[:billingAddress][:houseNumberOrName] = address[:address2] || 'N/A'
post[:billingAddress][:postalCode] = address[:zip] if address[:zip]
post[:billingAddress][:city] = address[:city] || 'N/A'
post[:billingAddress][:stateOrProvince] = address[:state] || 'N/A'
post[:billingAddress][:stateOrProvince] = get_state(address)
post[:billingAddress][:country] = address[:country] if address[:country]
end
end

def get_state(address)
address[:state] && !address[:state].blank? ? address[:state] : 'N/A'
end

def add_invoice(post, money, options)
currency = options[:currency] || currency(money)
amount = {
Expand Down
9 changes: 7 additions & 2 deletions test/remote/gateways/remote_adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -605,11 +605,16 @@ def test_blank_country_for_purchase
assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
end

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

def test_blank_state_for_purchase
@options[:billing_address][:state] = ''
response = @gateway.authorize(@amount, @credit_card, @options)
assert_failure response
assert_match Gateway::STANDARD_ERROR_CODE[:incorrect_address], response.error_code
assert_success response
end

def test_missing_phone_for_purchase
Expand Down

0 comments on commit 38327b3

Please sign in to comment.