Skip to content

Commit 6eb5e5c

Browse files
authored
Merge pull request #233 from maxmind/wstorey/eng-2871-eventparty-and-paymentmethod-minfraud-inputs-are-supported
Add /event/party, /payment/method, and new /event/type values
2 parents bc6585f + e37fafc commit 6eb5e5c

File tree

5 files changed

+56
-0
lines changed

5 files changed

+56
-0
lines changed

HISTORY.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ History
99
* Setuptools has been replaced with the uv build backend for building the
1010
package.
1111
* Added ``securepay`` to the ``/payment/processor`` validation.
12+
* Added ``credit_application`` and ``fund_transfer`` to the ``/event/type``
13+
validation.
14+
* Added the input ``/event/party``. This is the party submitting the
15+
transaction.
16+
* Added the input ``/payment/method``. This is the payment method associated
17+
with the transaction.
1218

1319
3.1.0 (2025-05-23)
1420
++++++++++++++++++

README.rst

Lines changed: 2 additions & 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',
@@ -209,6 +210,7 @@ Score, Insights and Factors Example
209210
>>> 'payment': {
210211
>>> 'decline_code': 'invalid number',
211212
>>> 'was_authorized': False,
213+
>>> 'method': 'card',
212214
>>> 'processor': 'stripe'
213215
>>> },
214216
>>> 'shopping_cart': [{

src/minfraud/validation.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,21 @@ def _hostname(hostname: str) -> str:
9898

9999
_shipping_address["delivery_speed"] = _delivery_speed
100100

101+
_payment_method = In(
102+
[
103+
"bank_debit",
104+
"bank_redirect",
105+
"bank_transfer",
106+
"buy_now_pay_later",
107+
"card",
108+
"crypto",
109+
"digital_wallet",
110+
"gift_card",
111+
"real_time_payment",
112+
"rewards",
113+
],
114+
)
115+
101116
_payment_processor = In(
102117
[
103118
"adyen",
@@ -281,11 +296,15 @@ def _credit_card_token(s: str) -> str:
281296
)
282297

283298

299+
_event_party = In(["agent", "customer"])
300+
284301
_event_type = In(
285302
[
286303
"account_creation",
287304
"account_login",
305+
"credit_application",
288306
"email_change",
307+
"fund_transfer",
289308
"password_reset",
290309
"payout_change",
291310
"purchase",
@@ -316,6 +335,7 @@ def _uri(s: str) -> str:
316335
},
317336
"billing": _address,
318337
"payment": {
338+
"method": _payment_method,
319339
"processor": _payment_processor,
320340
"was_authorized": bool,
321341
"decline_code": str,
@@ -346,6 +366,7 @@ def _uri(s: str) -> str:
346366
"domain": _hostname,
347367
},
348368
"event": {
369+
"party": _event_party,
349370
"shop_id": str,
350371
"time": _rfc3339_datetime,
351372
"type": _event_type,

tests/data/full-transaction-request.json

Lines changed: 2 additions & 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",
@@ -41,6 +42,7 @@
4142
"delivery_speed": "same_day"
4243
},
4344
"payment": {
45+
"method": "card",
4446
"processor": "stripe",
4547
"was_authorized": false,
4648
"decline_code": "invalid number"

tests/test_validation.py

Lines changed: 25 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

@@ -324,7 +330,9 @@ def test_type(self) -> None:
324330
for good in (
325331
"account_creation",
326332
"account_login",
333+
"credit_application",
327334
"email_change",
335+
"fund_transfer",
328336
"password_reset",
329337
"payout_change",
330338
"purchase",
@@ -370,6 +378,23 @@ def test_referrer_uri(self) -> None:
370378

371379

372380
class TestPayment(ValidationBase, unittest.TestCase):
381+
def test_method(self) -> None:
382+
for good in (
383+
"bank_debit",
384+
"bank_redirect",
385+
"bank_transfer",
386+
"buy_now_pay_later",
387+
"card",
388+
"crypto",
389+
"digital_wallet",
390+
"gift_card",
391+
"real_time_payment",
392+
"rewards",
393+
):
394+
self.check_transaction({"payment": {"method": good}})
395+
for bad in ("bad", 1, ""):
396+
self.check_invalid_transaction({"payment": {"method": bad}})
397+
373398
def test_processor(self) -> None:
374399
for good in ("adyen", "stripe"):
375400
self.check_transaction({"payment": {"processor": good}})

0 commit comments

Comments
 (0)