Skip to content

Add custom rule label and 3DS result input #84

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 7 commits into from
Aug 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ History
* ``dlocal``
* ``onpay``
* ``safecharge``
* Added ``rule_label`` to minFraud output ``/disposition``.
* Added ``was_3d_secure_successful`` to ``/credit_card`` validation

2.3.1 (2021-02-12)
++++++++++++++++++
Expand Down
1 change: 1 addition & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ Score, Insights and Factors Example
>>> 'cvv_result': 'N',
>>> 'bank_name': 'Bank of No Hope',
>>> 'issuer_id_number': '411111'
>>> 'was_3d_secure_successful': True
>>> },
>>> 'payment': {
>>> 'decline_code': 'invalid number',
Expand Down
15 changes: 13 additions & 2 deletions minfraud/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,8 +418,9 @@ class Disposition:
.. attribute:: action

The action to take on the transaction as defined by your custom rules.
The current set of values are "accept", "manual_review", and "reject".
If you do not have custom rules set up, ``None`` will be returned.
The current set of values are "accept", "manual_review", "reject", and
"test". If you do not have custom rules set up, ``None`` will be
returned.

:type: str | None

Expand All @@ -429,16 +430,26 @@ class Disposition:
"custom_rule", "block_list", and "default". If you do not have custom
rules set up, ``None`` will be returned.

:type: str | None

.. attribute:: rule_label

The label of the custom rule that was triggered. If you do not have
custom rules set up, the triggered custom rule does not have a label, or
no custom rule was triggered, ``None`` will be returned.

:type: str | None
"""

action: Optional[str]
reason: Optional[str]
rule_label: Optional[str]

__slots__ = ()
_fields = {
"action": None,
"reason": None,
"rule_label": None,
}


Expand Down
1 change: 1 addition & 0 deletions minfraud/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def _uri(s: str) -> str:
"issuer_id_number": _iin,
"last_4_digits": _credit_card_last_4,
"token": _credit_card_token,
"was_3d_secure_successful": bool,
},
"custom_inputs": {_custom_input_key: _custom_input_value},
"device": {
Expand Down
3 changes: 2 additions & 1 deletion tests/data/full-transaction-request.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@
"bank_phone_number": "123-456-1234",
"avs_result": "Y",
"cvv_result": "N",
"token": "123456abc1234"
"token": "123456abc1234",
"was_3d_secure_successful": true
},
"order": {
"amount": 323.21,
Expand Down
5 changes: 4 additions & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,13 @@ def test_device(self):
self.assertEqual(local_time, device.local_time)

def test_disposition(self):
disposition = Disposition({"action": "accept", "reason": "default"})
disposition = Disposition(
{"action": "accept", "reason": "default", "rule_label": "custom rule label"}
)

self.assertEqual("accept", disposition.action)
self.assertEqual("default", disposition.reason)
self.assertEqual("custom rule label", disposition.rule_label)

def test_email(self):
first_seen = "2016-01-01"
Expand Down
3 changes: 3 additions & 0 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,9 @@ def test_token(self):
for invalid in ("\x20", "123456", "x" * 256):
self.check_invalid_transaction({"credit_card": {"token": invalid}})

def test_was_3d_secure_successful(self):
self.check_bool("credit_card", "was_3d_secure_successful")


class TestCustomInputs(ValidationBase, unittest.TestCase):
def test_valid_inputs(self):
Expand Down