@@ -8,16 +8,18 @@ module Components
88 class CreditCard < Base
99 include Minfraud ::Validates
1010
11- # The issuer ID number for the credit card. This is the first 6 digits of
12- # the credit card number. It identifies the issuing bank.
11+ # The issuer ID number for the credit card. This is the first 6 or 8
12+ # digits of the credit card number. It identifies the issuing bank.
1313 #
1414 # @return [String, nil]
1515 attr_accessor :issuer_id_number
1616
17- # The last four digits of the credit card number.
17+ # The last two or four digits of the credit card number.
18+ #
19+ # @see https://dev.maxmind.com/minfraud/api-documentation/requests?lang=en#schema--request--credit-card__last_digits
1820 #
1921 # @return [String, nil]
20- attr_accessor :last_4_digits
22+ attr_accessor :last_digits
2123
2224 # The name of the issuing bank as provided by the end user.
2325 #
@@ -72,12 +74,30 @@ class CreditCard < Base
7274 # @return [Boolean, nil]
7375 attr_accessor :was_3d_secure_successful
7476
77+ # Get the last digits of the credit card number.
78+ #
79+ # @deprecated Use {::last_digits} instead.
80+ #
81+ # @return [String, nil]
82+ def last_4_digits
83+ @last_digits
84+ end
85+
86+ # Set the last digits of the credit card number.
87+ #
88+ # @deprecated Use {::last_digits} instead.
89+ #
90+ # @return [String, nil]
91+ def last_4_digits = ( last4 )
92+ @last_digits = last4
93+ end
94+
7595 # @param params [Hash] Hash of parameters. Each key/value should
7696 # correspond to one of the available attributes.
7797 def initialize ( params = { } )
7898 @bank_phone_country_code = params [ :bank_phone_country_code ]
7999 @issuer_id_number = params [ :issuer_id_number ]
80- @last_4_digits = params [ :last_4_digits ]
100+ @last_digits = params [ :last_digits ] || params [ :last_4_digits ]
81101 @bank_name = params [ :bank_name ]
82102 @bank_phone_number = params [ :bank_phone_number ]
83103 @avs_result = params [ :avs_result ]
@@ -94,8 +114,8 @@ def validate
94114 return if !Minfraud . enable_validation
95115
96116 validate_telephone_country_code ( 'bank_phone_country_code' , @bank_phone_country_code )
97- validate_regex ( 'issuer_id_number' , /\A [0-9]{6}\z / , @issuer_id_number )
98- validate_regex ( 'last_4_digits ' , /\A [0-9]{4} \z / , @last_4_digits )
117+ validate_regex ( 'issuer_id_number' , /\A (?: [0-9]{6}|[0-9]{8}) \z / , @issuer_id_number )
118+ validate_regex ( 'last_digits ' , /\A (?: [0-9]{2}|[0-9]{4}) \z / , @last_digits )
99119 validate_string ( 'bank_name' , 255 , @bank_name )
100120 validate_string ( 'bank_phone_number' , 255 , @bank_phone_number )
101121 validate_string ( 'avs_result' , 1 , @avs_result )
0 commit comments