11package com .maxmind .minfraud .request ;
22
3+ import com .fasterxml .jackson .annotation .JsonIgnore ;
34import com .fasterxml .jackson .annotation .JsonProperty ;
45import com .maxmind .minfraud .AbstractModel ;
56
1011 */
1112public final class CreditCard extends AbstractModel {
1213 private final String issuerIdNumber ;
13- private final String last4Digits ;
14+ private final String lastDigits ;
1415 private final String bankName ;
1516 private final String bankPhoneCountryCode ;
1617 private final String bankPhoneNumber ;
@@ -21,7 +22,7 @@ public final class CreditCard extends AbstractModel {
2122
2223 private CreditCard (CreditCard .Builder builder ) {
2324 issuerIdNumber = builder .issuerIdNumber ;
24- last4Digits = builder .last4Digits ;
25+ lastDigits = builder .lastDigits ;
2526 bankName = builder .bankName ;
2627 bankPhoneCountryCode = builder .bankPhoneCountryCode ;
2728 bankPhoneNumber = builder .bankPhoneNumber ;
@@ -36,12 +37,12 @@ private CreditCard(CreditCard.Builder builder) {
3637 * from values set by the builder's methods.
3738 */
3839 public static final class Builder {
39- private static final Pattern IIN_PATTERN = Pattern .compile ("^[0-9]{6}$" );
40- private static final Pattern LAST_4_PATTERN = Pattern .compile ("^[0-9]{4} $" );
40+ private static final Pattern IIN_PATTERN = Pattern .compile ("^(?: [0-9]{6}|[0-9]{8}) $" );
41+ private static final Pattern LAST_DIGITS_PATTERN = Pattern .compile ("^(?: [0-9]{2}|[0-9]{4}) $" );
4142 private static final Pattern TOKEN_PATTERN = Pattern .compile ("^(?![0-9]{1,19}$)[\\ x21-\\ x7E]{1,255}$" );
4243
4344 String issuerIdNumber ;
44- String last4Digits ;
45+ String lastDigits ;
4546 String bankName ;
4647 String bankPhoneCountryCode ;
4748 String bankPhoneNumber ;
@@ -52,7 +53,7 @@ public static final class Builder {
5253
5354 /**
5455 * @param number The issuer ID number for the credit card. This is the
55- * first 6 digits of the credit card number. It
56+ * first 6 or 8 digits of the credit card number. It
5657 * identifies the issuing bank.
5758 * @return The builder object.
5859 * @throws IllegalArgumentException when number is not a six digit
@@ -67,16 +68,30 @@ public CreditCard.Builder issuerIdNumber(String number) {
6768 }
6869
6970 /**
70- * @param digits The last four digits of the credit card number.
71+ * @deprecated
72+ * Use lastDigits instead.
73+ *
74+ * @param digits The last two or four digits of the credit card number.
7175 * @return The builder object.
72- * @throws IllegalArgumentException when number is not a four digit
76+ * @throws IllegalArgumentException when number is not a two or four digit
7377 * string.
7478 */
79+ @ Deprecated
7580 public CreditCard .Builder last4Digits (String digits ) {
76- if (!LAST_4_PATTERN .matcher (digits ).matches ()) {
77- throw new IllegalArgumentException ("The last 4 credit card digits " + digits + " are of the wrong format." );
81+ return this .lastDigits (digits );
82+ }
83+
84+ /**
85+ * @param digits The last two or four digits of the credit card number.
86+ * @return The builder object.
87+ * @throws IllegalArgumentException when number is not a two or four digit
88+ * string.
89+ */
90+ public CreditCard .Builder lastDigits (String digits ) {
91+ if (!LAST_DIGITS_PATTERN .matcher (digits ).matches ()) {
92+ throw new IllegalArgumentException ("The last credit card digits " + digits + " are of the wrong format." );
7893 }
79- last4Digits = digits ;
94+ lastDigits = digits ;
8095 return this ;
8196 }
8297
@@ -188,11 +203,22 @@ public String getIssuerIdNumber() {
188203 }
189204
190205 /**
191- * @return The last 4 digits of the credit card number.
206+ * @deprecated
207+ *
208+ * @return The last two or four digits of the credit card number.
192209 */
193- @ JsonProperty ("last_4_digits" )
210+ @ Deprecated
211+ @ JsonIgnore
194212 public String getLast4Digits () {
195- return last4Digits ;
213+ return this .getLastDigits ();
214+ }
215+
216+ /**
217+ * @return The last two or four digits of the credit card number.
218+ */
219+ @ JsonProperty ("last_digits" )
220+ public String getLastDigits () {
221+ return lastDigits ;
196222 }
197223
198224 /**
0 commit comments