Skip to content

Commit

Permalink
Worldpay: Update stored creds (#5114)
Browse files Browse the repository at this point in the history
* Worldpay: Update stored creds

COMP-42

Adds tests to ensure stored credentials are passed for
network tokens and adds the ability to override the NTID
from the standard framework

Test Summary
Local:
5867 tests, 79281 assertions, 0 failures, 23 errors, 0 pendings, 0 omissions, 0 notifications
99.608% passed
Unit:
117 tests, 662 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
Remote:
104 tests, 447 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
98.0769% passed

* remove ntid override

* add test

* changelog

* rubocop
  • Loading branch information
aenand committed May 8, 2024
1 parent 20474d5 commit a849db6
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@
* Litle: Update commodity code and line item total fields [yunnydang] #5115
* Cybersource Rest: Add support for network tokens [aenand] #5107
* Decidir: Add support for customer object [rachelkirk] #5071
* Worldpay: Add support for stored credentials with network tokens [aenand] #5114


== Version 1.135.0 (August 24, 2023)
Expand Down
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/worldpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,7 @@ def add_network_tokenization_card(xml, payment_method, options)
eci = eci_value(payment_method)
xml.eciIndicator eci if eci.present?
end
add_stored_credential_options(xml, options)
end
end

Expand Down
8 changes: 8 additions & 0 deletions test/remote/gateways/remote_worldpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,14 @@ def test_successful_purchase_with_network_token
assert_equal 'SUCCESS', response.message
end

def test_successful_purchase_with_network_token_and_stored_credentials
stored_credential_params = stored_credential(:initial, :unscheduled, :merchant)

assert response = @gateway.purchase(@amount, @nt_credit_card, @options.merge({ stored_credential: stored_credential_params }))
assert_success response
assert_equal 'SUCCESS', response.message
end

def test_successful_purchase_with_network_token_without_eci_visa
assert response = @gateway.purchase(@amount, @visa_nt_credit_card_without_eci, @options)
assert_success response
Expand Down
26 changes: 26 additions & 0 deletions test/unit/gateways/worldpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,32 @@ def test_authorize_passes_stored_credential_options
assert_success response
end

def test_authorize_with_nt_passes_stored_credential_options
options = @options.merge(
stored_credential_usage: 'USED',
stored_credential_initiated_reason: 'UNSCHEDULED',
stored_credential_transaction_id: '000000000000020005060720116005060'
)
response = stub_comms do
@gateway.authorize(@amount, @nt_credit_card, options)
end.check_request do |_endpoint, data, _headers|
assert_match(/<storedCredentials usage\=\"USED\" merchantInitiatedReason\=\"UNSCHEDULED\"\>/, data)
assert_match(/<schemeTransactionIdentifier\>000000000000020005060720116005060\<\/schemeTransactionIdentifier\>/, data)
end.respond_with(successful_authorize_response)
assert_success response
end

def test_authorize_with_nt_passes_standard_stored_credential_options
stored_credential_params = stored_credential(:used, :unscheduled, :merchant, network_transaction_id: 20_005_060_720_116_005_060)
response = stub_comms do
@gateway.authorize(@amount, @nt_credit_card, @options.merge({ stored_credential: stored_credential_params }))
end.check_request do |_endpoint, data, _headers|
assert_match(/<storedCredentials usage\=\"USED\" merchantInitiatedReason\=\"UNSCHEDULED\"\>/, data)
assert_match(/<schemeTransactionIdentifier\>20005060720116005060\<\/schemeTransactionIdentifier\>/, data)
end.respond_with(successful_authorize_response)
assert_success response
end

def test_authorize_passes_correct_stored_credential_options_for_first_recurring
options = @options.merge(
stored_credential_usage: 'FIRST',
Expand Down

0 comments on commit a849db6

Please sign in to comment.