Skip to content

Commit a1059bb

Browse files
committed
Revert "Disallow 4 digit last_digits for 8 digit iins"
This reverts commit 5dab3b9.
1 parent d72e332 commit a1059bb

File tree

3 files changed

+11
-24
lines changed

3 files changed

+11
-24
lines changed

lib/minfraud/components/credit_card.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,8 @@ def validate
115115

116116
validate_telephone_country_code('bank_phone_country_code', @bank_phone_country_code)
117117
validate_regex('issuer_id_number', /\A(?:[0-9]{6}|[0-9]{8})\z/, @issuer_id_number)
118-
validate_last_digits('last_digits', @last_digits, @issuer_id_number)
118+
validate_regex('last_digits', /\A(?:[0-9]{2}|[0-9]{4})\z/, @last_digits)
119+
validate_regex('last_4_digits', /\A(?:[0-9]{2}|[0-9]{4})\z/, @last_4_digits)
119120
validate_string('bank_name', 255, @bank_name)
120121
validate_string('bank_phone_number', 255, @bank_phone_number)
121122
validate_string('avs_result', 1, @avs_result)

lib/minfraud/validates.rb

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -70,18 +70,6 @@ def validate_credit_card_token(field, value)
7070
end
7171
end
7272

73-
def validate_last_digits(field, value, iin)
74-
return if !value
75-
76-
if !value.to_s.match(/\A(?:[0-9]{2}|[0-9]{4})\z/)
77-
raise InvalidInputError, "The #{field} value is not valid. It must be two or four digits."
78-
end
79-
80-
if iin.length == 8 && value.length != 2
81-
raise InvalidInputError, "The #{field} value is not valid. It must be two digits when using an eight digit issuer_id_number."
82-
end
83-
end
84-
8573
def validate_custom_input_value(field, value)
8674
return if !value
8775

spec/components/credit_card_spec.rb

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,17 +48,6 @@
4848
end.to raise_exception(Minfraud::InvalidInputError)
4949
end
5050

51-
it 'raises an exception for invalid values (eight digit issuer_id_number + 4 digit last_digits)' do
52-
expect do
53-
Minfraud::Components::CreditCard.new(
54-
issuer_id_number: '12345678',
55-
last_digits: '1234',
56-
token: 'abcd',
57-
was_3d_secure_successful: true,
58-
)
59-
end.to raise_exception(Minfraud::InvalidInputError)
60-
end
61-
6251
it 'does not raise an exception for valid values (deprecated last_4_digits)' do
6352
@cc = Minfraud::Components::CreditCard.new(
6453
issuer_id_number: '123456',
@@ -70,6 +59,15 @@
7059
expect(@cc.last_digits).to be('1234')
7160
end
7261

62+
it 'does not raise an exception for valid values (eight digit issuer_id_number)' do
63+
Minfraud::Components::CreditCard.new(
64+
issuer_id_number: '12345678',
65+
last_4_digits: '1234',
66+
token: 'abcd',
67+
was_3d_secure_successful: true,
68+
)
69+
end
70+
7371
it 'does not raise an exception for valid values (two digit last_digits)' do
7472
@cc = Minfraud::Components::CreditCard.new(
7573
issuer_id_number: '12345678',

0 commit comments

Comments
 (0)