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

CyberSource: handling not supported Network Token brands #4500

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
2 changes: 2 additions & 0 deletions lib/active_merchant/billing/gateways/cyber_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -802,6 +802,8 @@ def add_auth_network_tokenization(xml, payment_method, options)
xml.tag!('xid', Base64.encode64(cryptogram[20...40])) if cryptogram.bytes.count > 20
xml.tag!('reconciliationID', options[:reconciliation_id]) if options[:reconciliation_id]
end
else
raise ArgumentError.new("Payment method #{brand} is not supported, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html")
end
end

Expand Down
23 changes: 23 additions & 0 deletions test/unit/gateways/cyber_source_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,29 @@ def test_able_to_properly_handle_20bytes_cryptogram
end
end

def test_raises_error_on_network_token_with_an_underlying_discover_card
error = assert_raises ArgumentError do
credit_card = network_tokenization_credit_card('4111111111111111',
brand: 'discover',
payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=')

@gateway.authorize(100, credit_card, @options)
end
assert_equal 'Payment method discover is not supported, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html', error.message
end

def test_raises_error_on_network_token_with_an_underlying_apms
error = assert_raises ArgumentError do
credit_card = network_tokenization_credit_card('4111111111111111',
brand: 'sodexo',
payment_cryptogram: 'EHuWW9PiBkWvqE5juRwDzAUFBAk=')

@gateway.authorize(100, credit_card, @options)
end

assert_equal 'Payment method sodexo is not supported, check https://developer.cybersource.com/docs/cybs/en-us/payments/developer/all/rest/payments/CreatingOnlineAuth/CreatingAuthReqPNT.html', error.message
end

private

def options_with_normalized_3ds(
Expand Down