Skip to content

Commit

Permalink
CyberSource: Handle unsupported Network Token brands
Browse files Browse the repository at this point in the history
Summary:
------------------------------
This PR adds a check on Cybersource adapter to deal
with not supported brands on Network Tokens.

Closes #4500

Test Execution:
------------------------------
Remote
Finished in 91.83718 seconds.
115 tests, 590 assertions, 3 failures, 0 errors, 0 pendings,
0 omissions, 0 notifications
97.3913% passed

Unit
5266 tests, 76138 assertions, 0 failures, 0 errors, 0 pendings,
0 omissions, 0 notifications
100% passed

RuboCop:
------------------------------
746 files inspected, no offenses detected
  • Loading branch information
Heavyblade authored and curiousepic committed Aug 1, 2022
1 parent 45e40d2 commit 3407c02
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Expand Up @@ -79,6 +79,7 @@
* Shift4: Add default `numericId`, add `InterfaceVersion`, `InterfaceName`, and `CompanyName` header fields, change date time format and allow merchant time zone [ajawadmirza] #4509
* BraintreeBlue: Add support for partial capture [aenand] #4515
* Rapyd: Change key name to `network_transaction_id` [ajawadmirza] #4514
* CyberSource: Handle unsupported Network Token brands [heavyblade] #4500

== Version 1.126.0 (April 15th, 2022)
* Moneris: Add 3DS MPI field support [esmitperez] #4373
Expand Down
2 changes: 2 additions & 0 deletions lib/active_merchant/billing/gateways/cyber_source.rb
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
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

0 comments on commit 3407c02

Please sign in to comment.