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

Authnet: Parse card_type from response #3218

Closed
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
4 changes: 4 additions & 0 deletions lib/active_merchant/billing/gateways/authorize_net.rb
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,10 @@ def parse_normal(action, body)
(empty?(element.content) ? nil : element.content[-4..-1])
end

response[:card_type] = if(element = doc.at_xpath('//accountType'))
(empty?(element.content) ? nil : element.content)
end

response[:test_request] = if(element = doc.at_xpath('//testRequest'))
(empty?(element.content) ? nil : element.content)
end
Expand Down
1 change: 1 addition & 0 deletions test/remote/gateways/remote_authorize_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,7 @@ def test_bad_login
authorization_code
avs_result_code
card_code
card_type
cardholder_authentication_code
full_response_code
response_code
Expand Down
2 changes: 2 additions & 0 deletions test/unit/gateways/authorize_net_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,8 @@ def test_successful_authorization
assert_equal 'M', response.cvv_result['code']
assert_equal 'CVV matches', response.cvv_result['message']
assert_equal 'I00001', response.params['full_response_code']
assert_equal '0015', response.params['account_number']
assert_equal 'MasterCard', response.params['card_type']

assert_equal '508141794', response.authorization.split('#')[0]
assert response.test?
Expand Down