@@ -10,9 +10,12 @@ interface TransactionReportProps {
1010 */
1111 chargebackCode ?: string ;
1212 /**
13- * The IP address of the customer placing the order.
13+ * The IP address of the customer placing the order. This field is not
14+ * required if you provide at least one of the transaction's minfraudId,
15+ * maxmindId, or transactionId. You are encouraged to provide it, if
16+ * possible.
1417 */
15- ipAddress : string ;
18+ ipAddress ? : string ;
1619 /**
1720 * A unique eight character string identifying a minFraud Standard or
1821 * Premium request. These IDs are returned in the maxmindID field of a
@@ -23,8 +26,9 @@ interface TransactionReportProps {
2326 /**
2427 * A UUID that identifies a minFraud Score, minFraud Insights, or minFraud
2528 * Factors request. This ID is returned at /id in the response. This field
26- * is not required, but you are encouraged to provide it if the request was
27- * made to one of these services.
29+ * is not required if you provide at least one of the transaction's ipAddress,
30+ * minfraudId, or transactionId. You are encouraged to provide
31+ * it, if possible.
2832 */
2933 minfraudId ?: string ;
3034 /**
@@ -40,8 +44,8 @@ interface TransactionReportProps {
4044 tag : Tag ;
4145 /**
4246 * The transaction ID you originally passed to minFraud. This field is not
43- * required, but you are encouraged to provide it or the transaction’s
44- * maxmindId or minfraudId .
47+ * required if you provide at least one of the transaction's ipAddress,
48+ * minfraudId, or maxmindId. You are encouraged to provide it, if possible .
4549 */
4650 transactionId ?: string ;
4751}
@@ -50,7 +54,7 @@ export default class TransactionReport {
5054 /** @inheritDoc TransactionReportProps.chargebackCode */
5155 public chargebackCode ?: string ;
5256 /** @inheritDoc TransactionReportProps.ipAddress */
53- public ipAddress : string ;
57+ public ipAddress ? : string ;
5458 /** @inheritDoc TransactionReportProps.maxmindId */
5559 public maxmindId ?: string ;
5660 /** @inheritDoc TransactionReportProps.minfraudId */
@@ -63,12 +67,26 @@ export default class TransactionReport {
6367 public transactionId ?: string ;
6468
6569 public constructor ( transactionReport : TransactionReportProps ) {
66- if ( isIP ( transactionReport . ipAddress ) === 0 ) {
70+ // Check if at least one identifier field is set
71+ if (
72+ ! transactionReport . ipAddress &&
73+ ! transactionReport . maxmindId &&
74+ ! transactionReport . minfraudId &&
75+ ! transactionReport . transactionId
76+ ) {
6777 throw new ArgumentError (
68- '`transactionReport. ipAddress` is an invalid IP address '
78+ 'The report must contain at least one of the following fields: ` ipAddress`, `maxmindId`, `minfraudId`, `transactionId`. '
6979 ) ;
7080 }
7181
82+ if ( transactionReport . ipAddress ) {
83+ if ( isIP ( transactionReport . ipAddress ) === 0 ) {
84+ throw new ArgumentError (
85+ '`transactionReport.ipAddress` is an invalid IP address'
86+ ) ;
87+ }
88+ }
89+
7290 if (
7391 ! transactionReport . tag ||
7492 ! Object . values ( Tag ) . includes ( transactionReport . tag )
0 commit comments