Skip to content

Commit 2aa733b

Browse files
horghclaude
andcommitted
Add /event/party field with agent and customer values
Add new /event/party enum field to specify which party is submitting the transaction. Valid values are "agent" and "customer". The field is positioned first in the event object. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 5fb59c5 commit 2aa733b

File tree

5 files changed

+13
-0
lines changed

5 files changed

+13
-0
lines changed

HISTORY.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ History
1111
* Added ``securepay`` to the ``/payment/processor`` validation.
1212
* Added ``credit_application`` and ``fund_transfer`` to the ``/event/type``
1313
validation.
14+
* Added the input ``/event/party``. This is the party submitting the
15+
transaction.
1416

1517
3.1.0 (2025-05-23)
1618
++++++++++++++++++

README.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ Score, Insights and Factors Example
156156
>>> 'user_agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36'
157157
>>> },
158158
>>> 'event': {
159+
>>> 'party': 'customer',
159160
>>> 'shop_id': 's2123',
160161
>>> 'type': 'purchase',
161162
>>> 'transaction_id': 'txn3134133',

src/minfraud/validation.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,8 @@ def _credit_card_token(s: str) -> str:
281281
)
282282

283283

284+
_event_party = In(["agent", "customer"])
285+
284286
_event_type = In(
285287
[
286288
"account_creation",
@@ -348,6 +350,7 @@ def _uri(s: str) -> str:
348350
"domain": _hostname,
349351
},
350352
"event": {
353+
"party": _event_party,
351354
"shop_id": str,
352355
"time": _rfc3339_datetime,
353356
"type": _event_type,

tests/data/full-transaction-request.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"event": {
3+
"party": "customer",
34
"transaction_id": "txn3134133",
45
"shop_id": "s2123",
56
"time": "2014-04-12T23:20:50.052+00:00",

tests/test_validation.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,12 @@ def test_domain(self) -> None:
308308

309309

310310
class TestEvent(ValidationBase, unittest.TestCase):
311+
def test_party(self) -> None:
312+
for good in ("agent", "customer"):
313+
self.check_transaction({"event": {"party": good}})
314+
for bad in ("bad", 1, ""):
315+
self.check_invalid_transaction({"event": {"party": bad}})
316+
311317
def test_transaction(self) -> None:
312318
self.check_transaction_str_type("event", "transaction_id")
313319

0 commit comments

Comments
 (0)