Skip to content

Commit

Permalink
RedsysRest: Omit CVV from requests when not present
Browse files Browse the repository at this point in the history
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
  • Loading branch information
jcreiff committed Apr 1, 2024
1 parent 5918a42 commit 09b6647
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/gateways/redsys_rest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 8 additions & 0 deletions test/remote/gateways/remote_redsys_rest_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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')

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 09b6647

Please sign in to comment.