@@ -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 minfraud_id,
15+ * maxmind_id, or transaction_id. 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
30+ * minfraud_id, maxmind_id, or transaction_id. You are encouraged to provide
31+ * it, if possible.
2832 */
2933 minfraudId ?: string ;
3034 /**
@@ -40,8 +44,9 @@ 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 minfraud_id,
48+ * maxmind_id, or transaction_id. You are encouraged to provide it, if
49+ * possible.
4550 */
4651 transactionId ?: string ;
4752}
@@ -50,7 +55,7 @@ export default class TransactionReport {
5055 /** @inheritDoc TransactionReportProps.chargebackCode */
5156 public chargebackCode ?: string ;
5257 /** @inheritDoc TransactionReportProps.ipAddress */
53- public ipAddress : string ;
58+ public ipAddress ? : string ;
5459 /** @inheritDoc TransactionReportProps.maxmindId */
5560 public maxmindId ?: string ;
5661 /** @inheritDoc TransactionReportProps.minfraudId */
@@ -63,12 +68,26 @@ export default class TransactionReport {
6368 public transactionId ?: string ;
6469
6570 public constructor ( transactionReport : TransactionReportProps ) {
66- if ( isIP ( transactionReport . ipAddress ) === 0 ) {
71+ // Check if at least one identifier field is set
72+ if (
73+ ! transactionReport . ipAddress &&
74+ ! transactionReport . maxmindId &&
75+ ! transactionReport . minfraudId &&
76+ ! transactionReport . transactionId
77+ ) {
6778 throw new ArgumentError (
68- '`transactionReport. ipAddress` is an invalid IP address '
79+ 'The report must contain at least one of the following fields: ` ipAddress`, `maxmindId`, `minfraudId`, `transactionId`. '
6980 ) ;
7081 }
7182
83+ if ( transactionReport . ipAddress ) {
84+ if ( isIP ( transactionReport . ipAddress ) === 0 ) {
85+ throw new ArgumentError (
86+ '`transactionReport.ipAddress` is an invalid IP address'
87+ ) ;
88+ }
89+ }
90+
7291 if (
7392 ! transactionReport . tag ||
7493 ! Object . values ( Tag ) . includes ( transactionReport . tag )
0 commit comments