diff --git a/lib/active_merchant/billing/gateways/decidir.rb b/lib/active_merchant/billing/gateways/decidir.rb index 58167d5ede8..b534beaa0c1 100644 --- a/lib/active_merchant/billing/gateways/decidir.rb +++ b/lib/active_merchant/billing/gateways/decidir.rb @@ -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, diff --git a/test/unit/gateways/decidir_test.rb b/test/unit/gateways/decidir_test.rb index be2c78a3f96..2f2dfb4e174 100644 --- a/test/unit/gateways/decidir_test.rb +++ b/test/unit/gateways/decidir_test.rb @@ -43,7 +43,8 @@ def setup '4012001037141112', brand: 'visa', eci: '05', - payment_cryptogram: '000203016912340000000FA08400317500000000' + payment_cryptogram: '000203016912340000000FA08400317500000000', + verification_value: '123' ) end @@ -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