From 09b6647dc90e6f67ef764a06ba091e0abf001817 Mon Sep 17 00:00:00 2001 From: Joe Reiff Date: Mon, 1 Apr 2024 12:44:45 -0400 Subject: [PATCH] RedsysRest: Omit CVV from requests when not present LOCAL 5838 tests, 79229 assertions, 2 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 99.9657% passed 792 files inspected, no offenses detected UNIT 23 tests, 101 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 100% passed REMOTE 19 tests, 41 assertions, 9 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications 52.6316% passed CER-1413 --- CHANGELOG | 1 + lib/active_merchant/billing/gateways/redsys_rest.rb | 2 +- test/remote/gateways/remote_redsys_rest_test.rb | 8 ++++++++ 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 8a813b526aa..d6c17c84bcf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -135,6 +135,7 @@ * XPay: Refactor basic transactions after implement 3DS 3steps API [sinourain] #5058 * AuthorizeNet: Remove turn_on_nt flow [almalee24] #5056 * CheckoutV2: Add processing and recipient fields [yunnydang] #5068 +* RedsysRest: Omit CVV from requests when not present [jcreiff] #5077 == Version 1.135.0 (August 24, 2023) * PaymentExpress: Correct endpoints [steveh] #4827 diff --git a/lib/active_merchant/billing/gateways/redsys_rest.rb b/lib/active_merchant/billing/gateways/redsys_rest.rb index 62439ca475f..4f5414aefd8 100644 --- a/lib/active_merchant/billing/gateways/redsys_rest.rb +++ b/lib/active_merchant/billing/gateways/redsys_rest.rb @@ -332,7 +332,7 @@ def add_payment(post, card) post['DS_MERCHANT_TITULAR'] = CGI.escape(name) post['DS_MERCHANT_PAN'] = card.number post['DS_MERCHANT_EXPIRYDATE'] = "#{year[2..3]}#{month}" - post['DS_MERCHANT_CVV2'] = card.verification_value + post['DS_MERCHANT_CVV2'] = card.verification_value if card.verification_value? end def determine_action(options) diff --git a/test/remote/gateways/remote_redsys_rest_test.rb b/test/remote/gateways/remote_redsys_rest_test.rb index 19fb1298cca..6c4f2361e59 100644 --- a/test/remote/gateways/remote_redsys_rest_test.rb +++ b/test/remote/gateways/remote_redsys_rest_test.rb @@ -5,6 +5,7 @@ def setup @gateway = RedsysRestGateway.new(fixtures(:redsys_rest)) @amount = 100 @credit_card = credit_card('4548812049400004') + @credit_card_no_cvv = credit_card('4548812049400004', verification_value: nil) @declined_card = credit_card @threeds2_credit_card = credit_card('4918019199883839') @@ -109,6 +110,13 @@ def test_successful_verify assert_equal 'Transaction Approved', response.message end + def test_successful_verify_without_cvv + assert response = @gateway.verify(@credit_card_no_cvv, @options) + assert_success response + + assert_equal 'Transaction Approved', response.message + end + def test_unsuccessful_verify assert response = @gateway.verify(@declined_card, @options) assert_failure response