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

Global Collect: Only add name if present #3268

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 2 additions & 6 deletions lib/active_merchant/billing/gateways/global_collect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,8 @@ def add_payment(post, payment, options)

def add_customer_data(post, options, payment = nil)
if payment
post['order']['customer']['personalInformation'] = {
'name' => {
'firstName' => payment.first_name[0..14],
'surname' => payment.last_name[0..69]
}
}
post['order']['customer']['personalInformation']['name']['firstName'] = payment.first_name[0..14] if payment.first_name
post['order']['customer']['personalInformation']['name']['surname'] = payment.last_name[0..69] if payment.last_name
end
post['order']['customer']['merchantCustomerId'] = options[:customer] if options[:customer]
post['order']['customer']['companyInformation']['name'] = options[:company] if options[:company]
Expand Down
10 changes: 9 additions & 1 deletion test/remote/gateways/remote_global_collect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@ def test_successful_purchase_with_very_long_name
assert_equal 'Succeeded', response.message
end

def test_successful_purchase_with_blank_name
credit_card = credit_card('4567350000427977', { first_name: nil, last_name: nil})

response = @gateway.purchase(@amount, credit_card, @options)
assert_success response
assert_equal 'Succeeded', response.message
end

def test_failed_purchase
response = @gateway.purchase(@rejected_amount, @declined_card, @options)
assert_failure response
Expand Down Expand Up @@ -155,7 +163,7 @@ def test_invalid_login

response = gateway.purchase(@amount, @credit_card, @options)
assert_failure response
assert_match %r{UNKNOWN_SERVER_ERROR}, response.message
assert_match %r{MISSING_OR_INVALID_AUTHORIZATION}, response.message
end

def test_transcript_scrubbing
Expand Down
10 changes: 10 additions & 0 deletions test/unit/gateways/global_collect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,16 @@ def test_trucates_first_name_to_15_chars
assert_equal '000000142800000000920000100001', response.authorization
end

def test_handles_blank_names
credit_card = credit_card('4567350000427977', { first_name: nil, last_name: nil})

response = stub_comms do
@gateway.authorize(@accepted_amount, credit_card, @options)
end.respond_with(successful_authorize_response)

assert_success response
end

def test_failed_authorize
response = stub_comms do
@gateway.authorize(@rejected_amount, @declined_card, @options)
Expand Down