@@ -10,7 +10,10 @@ class Transaction < Base
1010 include ::Minfraud ::Enum
1111
1212 # The IP address of the customer placing the order. This should be
13- # passed as a string like "152.216.7.110".
13+ # passed as a string like "152.216.7.110". This field is not required
14+ # 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 #
1518 # @return [String, nil]
1619 attr_accessor :ip_address
@@ -34,16 +37,19 @@ class Transaction < Base
3437
3538 # A unique eight character string identifying a minFraud Standard or
3639 # Premium request. These IDs are returned in the maxmindID field of a
37- # response for a successful minFraud request. This field is not
38- # required, but you are encouraged to provide it, if possible.
40+ # response for a successful minFraud request. This field is not required
41+ # if you provide at least one of the transaction's ip_address,
42+ # maxmind_id, or transaction_id. You are encouraged to provide it, if
43+ # possible.
3944 #
4045 # @return [String, nil]
4146 attr_accessor :maxmind_id
4247
4348 # A UUID that identifies a minFraud Score, minFraud Insights, or
4449 # minFraud Factors request. This ID is returned at /id in the response.
45- # This field is not required, but you are encouraged to provide it if
46- # the request was made to one of these services.
50+ # This field is not required if you provide at least one of the
51+ # transaction's ip_address, maxmind_id, or transaction_id. You are
52+ # encouraged to provide it, if possible.
4753 #
4854 # @return [String, nil]
4955 attr_accessor :minfraud_id
@@ -56,9 +62,10 @@ class Transaction < Base
5662 # @return [String, nil]
5763 attr_accessor :notes
5864
59- # The transaction ID you originally passed to minFraud. This field is
60- # not required, but you are encouraged to provide it or the
61- # transaction's maxmind_id or minfraud_id.
65+ # The transaction ID you originally passed to minFraud. This field
66+ # is not required if you provide at least one of the transaction's
67+ # ip_address, maxmind_id, or minfraud_id. You are encouraged to
68+ # provide it, if possible.
6269 #
6370 # @return [String, nil]
6471 attr_accessor :transaction_id
@@ -73,6 +80,21 @@ def initialize(params = {})
7380 @notes = params [ :notes ]
7481 @transaction_id = params [ :transaction_id ]
7582 self . tag = params [ :tag ]
83+
84+ validate
85+ end
86+
87+ private
88+
89+ def validate
90+ return if !Minfraud . enable_validation
91+
92+ if ip_address . nil? &&
93+ minfraud_id . nil? &&
94+ ( maxmind_id . nil? || maxmind_id . empty? ) &&
95+ ( transaction_id . nil? || transaction_id . empty? )
96+ raise ArgumentError , 'At least one of the following is required: ip_address, minfraud_id, maxmind_id, transaction_id.'
97+ end
7698 end
7799 end
78100 end
0 commit comments