Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adyen: Replace empty state string with N/A #3252

Merged
merged 1 commit into from
Jul 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻

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