Skip to content

Commit

Permalink
Decidir: Pass CVV for NT
Browse files Browse the repository at this point in the history
This changes will allow CVV to be passed for NTs.

Remote
27 tests, 97 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
Alma Malambo committed Aug 9, 2024
1 parent f52d344 commit 60df77e
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/active_merchant/billing/gateways/decidir.rb
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,7 @@ def add_network_token(post, payment_method, options)
post[:fraud_detection] ||= {}
post[:fraud_detection][:sent_to_cs] = false
post[:card_data][:last_four_digits] = options[:last_4]
post[:card_data][:security_code] = payment_method.verification_value if payment_method.verification_value? && options[:pass_cvv_for_nt]

post[:token_card_data] = {
token: payment_method.number,
Expand Down
33 changes: 30 additions & 3 deletions test/unit/gateways/decidir_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ def setup
'4012001037141112',
brand: 'visa',
eci: '05',
payment_cryptogram: '000203016912340000000FA08400317500000000'
payment_cryptogram: '000203016912340000000FA08400317500000000',
verification_value: '123'
)
end

Expand Down Expand Up @@ -407,8 +408,34 @@ def test_network_token_payment_method
card_holder_identification_number: '44444444',
last_4: @credit_card.last_digits
}
@gateway_for_auth.expects(:ssl_request).returns(successful_network_token_response)
response = @gateway_for_auth.authorize(100, @network_token, options)

response = stub_comms(@gateway_for_auth, :ssl_request) do
@gateway_for_auth.authorize(100, @network_token, options.merge(pass_cvv_for_nt: true))
end.check_request do |_method, _endpoint, data, _headers|
assert_match(/"cryptogram\":\"#{@network_token.payment_cryptogram}\"/, data)
assert_match(/"security_code\":\"#{@network_token.verification_value}\"/, data)
end.respond_with(successful_network_token_response)

assert_success response
assert_equal 49120515, response.authorization
end

def test_network_token_payment_method_without_cvv
options = {
card_holder_name: 'Tesest payway',
card_holder_door_number: 1234,
card_holder_birthday: '200988',
card_holder_identification_type: 'DNI',
card_holder_identification_number: '44444444',
last_4: @credit_card.last_digits
}

response = stub_comms(@gateway_for_auth, :ssl_request) do
@gateway_for_auth.authorize(100, @network_token, options)
end.check_request do |_method, _endpoint, data, _headers|
assert_match(/"cryptogram\":\"#{@network_token.payment_cryptogram}\"/, data)
assert_not_match(/"security_code\":\"#{@network_token.verification_value}\"/, data)
end.respond_with(successful_network_token_response)

assert_success response
assert_equal 49120515, response.authorization
Expand Down

0 comments on commit 60df77e

Please sign in to comment.