Skip to content

Commit

Permalink
Adyen: Remove cryptogram flag
Browse files Browse the repository at this point in the history
Remote
146 tests, 468 assertions, 12 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
91.7808% passed
  • Loading branch information
Alma Malambo committed Oct 16, 2024
1 parent f65b11d commit ec93b3a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
* DLocal: Add the description field for refund [yunnydang] #5296
* Worldpay: Add support for Worldpay decrypted apple pay and google pay [dustinhaefele] #5271
* Orbital: Update alternate_ucaf_flow [almalee24] #5282
* Adyen: Remove cryptogram flag [almalee24] #5300

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
14 changes: 6 additions & 8 deletions lib/active_merchant/billing/gateways/adyen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -653,15 +653,13 @@ def add_network_tokenization_card(post, payment, options)
directoryResponse: 'Y',
eci: payment.eci || '07'
}
if payment.try(:network_token?) && options[:switch_cryptogram_mapping_nt]
post[:mpiData][:tokenAuthenticationVerificationValue] = payment.payment_cryptogram
else
post[:mpiData][:cavv] = payment.payment_cryptogram
end

cryptogram_field = payment.try(:network_token?) ? :tokenAuthenticationVerificationValue : :cavv
post[:mpiData][cryptogram_field] = payment.payment_cryptogram
end

def add_recurring_contract(post, options = {}, payment = nil)
return unless options[:recurring_contract_type] || (payment.try(:network_token?) && options[:switch_cryptogram_mapping_nt])
return unless options[:recurring_contract_type] || payment.try(:network_token?)

post[:recurring] ||= {}
post[:recurring][:contract] = options[:recurring_contract_type] if options[:recurring_contract_type]
Expand All @@ -670,7 +668,7 @@ def add_recurring_contract(post, options = {}, payment = nil)
post[:recurring][:recurringFrequency] = options[:recurring_frequency] if options[:recurring_frequency]
post[:recurring][:tokenService] = options[:token_service] if options[:token_service]

if payment.try(:network_token?) && options[:switch_cryptogram_mapping_nt]
if payment.try(:network_token?)
post[:recurring][:contract] = 'EXTERNAL'
post[:recurring][:tokenService] = case payment.brand
when 'visa' then 'VISATOKENSERVICE'
Expand Down Expand Up @@ -1002,7 +1000,7 @@ def card_not_stored?(response)

def skip_mpi_data?(options = {})
# Skips adding the NT mpi data if it is explicitly skipped in options, or if it is MIT and not the initial transaction.
options[:skip_mpi_data] == 'Y' || options[:wallet_type] || (!options.dig(:stored_credential, :initial_transaction) && options.dig(:stored_credential, :initiator) == 'merchant' && options[:switch_cryptogram_mapping_nt])
options[:skip_mpi_data] == 'Y' || options[:wallet_type] || (!options.dig(:stored_credential, :initial_transaction) && options.dig(:stored_credential, :initiator) == 'merchant')
end

def ecommerce_shopper_interaction?(payment, options)
Expand Down
22 changes: 7 additions & 15 deletions test/remote/gateways/remote_adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def test_successful_authorize_with_3ds2_browser_client_data
end

def test_successful_authorize_with_network_token
response = @gateway.authorize(@amount, @nt_credit_card, @options.merge(switch_cryptogram_mapping_nt: true))
response = @gateway.authorize(@amount, @nt_credit_card, @options)
assert_success response
assert_equal 'Authorised', response.message
end
Expand Down Expand Up @@ -562,13 +562,7 @@ def test_successful_purchase_with_shipping_default_country_code
end

def test_successful_purchase_with_apple_pay
response = @gateway.purchase(@amount, @apple_pay_card, @options.merge(switch_cryptogram_mapping_nt: true))
assert_success response
assert_equal '[capture-received]', response.message
end

def test_successful_purchase_with_apple_pay_with_ld_flag_false
response = @gateway.purchase(@amount, @apple_pay_card, @options.merge(switch_cryptogram_mapping_nt: false))
response = @gateway.purchase(@amount, @apple_pay_card, @options)
assert_success response
assert_equal '[capture-received]', response.message
end
Expand All @@ -586,7 +580,7 @@ def test_succesful_purchase_with_brand_override_with_execute_threed_false
end

def test_successful_purchase_with_google_pay
response = @gateway.purchase(@amount, @google_pay_card, @options.merge(switch_cryptogram_mapping_nt: true))
response = @gateway.purchase(@amount, @google_pay_card, @options)
assert_success response
assert_equal '[capture-received]', response.message
end
Expand Down Expand Up @@ -622,7 +616,7 @@ def test_successful_purchase_with_google_pay_without_billing_address_and_address
end

def test_successful_purchase_with_google_pay_and_truncate_order_id
response = @gateway.purchase(@amount, @google_pay_card, @options.merge(order_id: @long_order_id, switch_cryptogram_mapping_nt: true))
response = @gateway.purchase(@amount, @google_pay_card, @options.merge(order_id: @long_order_id))
assert_success response
assert_equal '[capture-received]', response.message
end
Expand All @@ -646,7 +640,7 @@ def test_successful_purchase_with_unionpay_card
end

def test_successful_purchase_with_network_token
response = @gateway.purchase(@amount, @nt_credit_card, @options.merge(switch_cryptogram_mapping_nt: true))
response = @gateway.purchase(@amount, @nt_credit_card, @options)
assert_success response
assert_equal '[capture-received]', response.message
end
Expand Down Expand Up @@ -1462,8 +1456,7 @@ def test_purchase_with_skip_mpi_data
first_options = options.merge(
order_id: generate_unique_id,
shopper_interaction: 'Ecommerce',
recurring_processing_model: 'Subscription',
switch_cryptogram_mapping_nt: true
recurring_processing_model: 'Subscription'
)
assert auth = @gateway.authorize(@amount, @apple_pay_card, first_options)
assert_success auth
Expand All @@ -1478,8 +1471,7 @@ def test_purchase_with_skip_mpi_data
skip_mpi_data: 'Y',
shopper_interaction: 'ContAuth',
recurring_processing_model: 'Subscription',
network_transaction_id: auth.network_transaction_id,
switch_cryptogram_mapping_nt: true
network_transaction_id: auth.network_transaction_id
)

assert purchase = @gateway.purchase(@amount, @apple_pay_card, used_options)
Expand Down
8 changes: 4 additions & 4 deletions test/unit/gateways/adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1258,7 +1258,7 @@ def test_authorize_with_network_tokenization_credit_card_no_name

def test_authorize_with_network_tokenization_credit_card
response = stub_comms do
@gateway.authorize(@amount, @apple_pay_card, @options.merge(switch_cryptogram_mapping_nt: false))
@gateway.authorize(@amount, @apple_pay_card, @options)
end.check_request do |_endpoint, data, _headers|
parsed = JSON.parse(data)
assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', parsed['mpiData']['cavv']
Expand Down Expand Up @@ -1296,7 +1296,7 @@ def test_authorize_with_google_pay_pan_only

def test_authorize_with_network_tokenization_credit_card_using_ld_option
response = stub_comms do
@gateway.authorize(@amount, @apple_pay_card, @options.merge(switch_cryptogram_mapping_nt: true))
@gateway.authorize(@amount, @apple_pay_card, @options)
end.check_request do |_endpoint, data, _headers|
parsed = JSON.parse(data)
assert_equal 'YwAAAAAABaYcCMX/OhNRQAAAAAA=', parsed['mpiData']['cavv']
Expand All @@ -1308,7 +1308,7 @@ def test_authorize_with_network_tokenization_credit_card_using_ld_option

def test_authorize_with_network_tokenization_credit_card_no_apple_no_google
response = stub_comms do
@gateway.authorize(@amount, @nt_credit_card, @options.merge(switch_cryptogram_mapping_nt: true))
@gateway.authorize(@amount, @nt_credit_card, @options)
end.check_request do |_endpoint, data, _headers|
parsed = JSON.parse(data)
assert_equal 'EHuWW9PiBkWvqE5juRwDzAUFBAk=', parsed['mpiData']['tokenAuthenticationVerificationValue']
Expand All @@ -1323,7 +1323,7 @@ def test_authorize_with_network_tokenization_credit_card_no_apple_no_google
def test_authorize_with_network_tokenization_credit_card_and_stored_credentials
stored_credential = stored_credential(:merchant, :recurring)
response = stub_comms do
@gateway.authorize(@amount, @nt_credit_card, @options.merge(switch_cryptogram_mapping_nt: true, stored_credential: stored_credential))
@gateway.authorize(@amount, @nt_credit_card, @options.merge(stored_credential: stored_credential))
end.check_request do |_endpoint, data, _headers|
parsed = JSON.parse(data)
assert_equal 'Ecommerce', parsed['shopperInteraction']
Expand Down

0 comments on commit ec93b3a

Please sign in to comment.