Skip to content

Commit

Permalink
Does not fail validation for blank cvv on maestro cards (#3082)
Browse files Browse the repository at this point in the history
This change is allowing users to pass `cvv: blank` and pass validation
even when `CreditCard.require_verification_value = true` for maestro,
since cvv length is 0
  • Loading branch information
filipebarcos authored Dec 17, 2018
1 parent 9c1d234 commit 7c77c2f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/active_merchant/billing/credit_card.rb
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,7 @@ def validate_verification_value #:nodoc:
unless valid_card_verification_value?(verification_value, brand)
errors << [:verification_value, "should be #{card_verification_value_length(brand)} digits"]
end
elsif requires_verification_value?
elsif requires_verification_value? && !valid_card_verification_value?(verification_value, brand)
errors << [:verification_value, 'is required']
end
errors
Expand Down
5 changes: 5 additions & 0 deletions test/unit/credit_card_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ def test_should_be_a_valid_maestro_card
assert_valid @maestro
end

def test_should_be_a_valid_maestro_card_when_require_cvv_is_true
CreditCard.require_verification_value = true
assert_valid @maestro
end

def test_cards_with_empty_names_should_not_be_valid
@visa.first_name = ''
@visa.last_name = ''
Expand Down

0 comments on commit 7c77c2f

Please sign in to comment.