@@ -1075,6 +1075,146 @@ class Subscores:
10751075 }
10761076
10771077
1078+ @_inflate_to_namedtuple
1079+ class Reason :
1080+ """The risk score reason for the multiplier.
1081+
1082+ This class provides both a machine-readable code and a human-readable
1083+ explanation of the reason for the risk score.
1084+
1085+ Although more codes_ may be added in the future, the current codes are:
1086+
1087+ - ``BROWSER_LANGUAGE`` - Riskiness of the browser user-agent and
1088+ language associated with the request.
1089+ - ``BUSINESS_ACTIVITY`` - Riskiness of business activity
1090+ associated with the request.
1091+ - ``COUNTRY`` - Riskiness of the country associated with the request.
1092+ - ``CUSTOMER_ID`` - Riskiness of a customer's activity.
1093+ - ``EMAIL_DOMAIN`` - Riskiness of email domain.
1094+ - ``EMAIL_DOMAIN_NEW`` - Riskiness of newly-sighted email domain.
1095+ - ``EMAIL_ADDRESS_NEW`` - Riskiness of newly-sighted email address.
1096+ - ``EMAIL_LOCAL_PART`` - Riskiness of the local part of the email address.
1097+ - ``EMAIL_VELOCITY`` - Velocity on email - many requests on same email
1098+ over short period of time.
1099+ - ``ISSUER_ID_NUMBER_COUNTRY_MISMATCH`` - Riskiness of the country mismatch
1100+ between IP, billing, shipping and IIN country.
1101+ - ``ISSUER_ID_NUMBER_ON_SHOP_ID`` - Risk of Issuer ID Number for the shop ID.
1102+ - ``ISSUER_ID_NUMBER_LAST_DIGITS_ACTIVITY`` - Riskiness of many recent requests
1103+ and previous high-risk requests on the IIN and last digits of the credit card.
1104+ - ``ISSUER_ID_NUMBER_SHOP_ID_VELOCITY`` - Risk of recent Issuer ID Number activity
1105+ for the shop ID.
1106+ - ``INTRACOUNTRY_DISTANCE`` - Risk of distance between IP, billing,
1107+ and shipping location.
1108+ - ``ANONYMOUS_IP`` - Risk due to IP being an Anonymous IP.
1109+ - ``IP_BILLING_POSTAL_VELOCITY`` - Velocity of distinct billing postal code
1110+ on IP address.
1111+ - ``IP_EMAIL_VELOCITY`` - Velocity of distinct email address on IP address.
1112+ - ``IP_HIGH_RISK_DEVICE`` - High-risk device sighted on IP address.
1113+ - ``IP_ISSUER_ID_NUMBER_VELOCITY`` - Velocity of distinct IIN on IP address.
1114+ - ``IP_ACTIVITY`` - Riskiness of IP based on minFraud network activity.
1115+ - ``LANGUAGE`` - Riskiness of browser language.
1116+ - ``MAX_RECENT_EMAIL`` - Riskiness of email address
1117+ based on past minFraud risk scores on email.
1118+ - ``MAX_RECENT_PHONE`` - Riskiness of phone number
1119+ based on past minFraud risk scores on phone.
1120+ - ``MAX_RECENT_SHIP`` - Riskiness of email address
1121+ based on past minFraud risk scores on ship address.
1122+ - ``MULTIPLE_CUSTOMER_ID_ON_EMAIL`` - Riskiness of email address
1123+ having many customer IDs.
1124+ - ``ORDER_AMOUNT`` - Riskiness of the order amount.
1125+ - ``ORG_DISTANCE_RISK`` - Risk of ISP and distance between
1126+ billing address and IP location.
1127+ - ``PHONE`` - Riskiness of the phone number or related numbers.
1128+ - ``CART`` - Riskiness of shopping cart contents.
1129+ - ``TIME_OF_DAY`` - Risk due to local time of day.
1130+ - ``TRANSACTION_REPORT_EMAIL`` - Risk due to transaction reports
1131+ on the email address.
1132+ - ``TRANSACTION_REPORT_IP`` - Risk due to transaction reports on the IP address.
1133+ - ``TRANSACTION_REPORT_PHONE`` - Risk due to transaction reports
1134+ on the phone number.
1135+ - ``TRANSACTION_REPORT_SHIP`` - Risk due to transaction reports
1136+ on the shipping address.
1137+ - ``EMAIL_ACTIVITY`` - Riskiness of the email address
1138+ based on minFraud network activity.
1139+ - ``PHONE_ACTIVITY`` - Riskiness of the phone number
1140+ based on minFraud network activity.
1141+ - ``SHIP_ACTIVITY`` - Riskiness of ship address based on minFraud network activity.
1142+
1143+ .. _codes: https://dev.maxmind.com/minfraud/api-documentation/responses\
1144+ /#schema--response--risk-score-reason--multiplier-reason
1145+
1146+ .. attribute:: code
1147+
1148+ This value is a machine-readable code identifying the
1149+ reason.
1150+
1151+ :type: str | None
1152+
1153+ .. attribute:: reason
1154+
1155+ This property provides a human-readable explanation of the
1156+ reason. The text may change at any time and should not be matched
1157+ against.
1158+
1159+ :type: str | None
1160+ """
1161+
1162+ code : Optional [str ]
1163+ reason : Optional [str ]
1164+
1165+ __slots__ = ()
1166+ _fields = {
1167+ "code" : None ,
1168+ "reason" : None ,
1169+ }
1170+
1171+
1172+ def _create_reasons (reasons : Optional [List [Dict [str , str ]]]) -> Tuple [Reason , ...]:
1173+ if not reasons :
1174+ return ()
1175+ return tuple (Reason (x ) for x in reasons ) # type: ignore
1176+
1177+
1178+ @_inflate_to_namedtuple
1179+ class RiskScoreReason :
1180+ """The risk score multiplier and the reasons for that multiplier.
1181+
1182+ .. attribute:: multiplier
1183+
1184+ The factor by which the risk score is increased (if the value is greater than 1)
1185+ or decreased (if the value is less than 1) for given risk reason(s).
1186+ Multipliers greater than 1.5 and less than 0.66 are considered significant
1187+ and lead to risk reason(s) being present.
1188+
1189+ :type: float | None
1190+
1191+ .. attribute:: reasons
1192+
1193+ This tuple contains :class:`.Reason` objects that describe
1194+ one of the reasons for the multiplier.
1195+
1196+ :type: tuple[Reason]
1197+
1198+ """
1199+
1200+ multiplier : float
1201+ reasons : Tuple [Reason , ...]
1202+
1203+ __slots__ = ()
1204+ _fields = {
1205+ "multiplier" : None ,
1206+ "reasons" : _create_reasons ,
1207+ }
1208+
1209+
1210+ def _create_risk_score_reasons (
1211+ risk_score_reasons : Optional [List [Dict [str , str ]]]
1212+ ) -> Tuple [RiskScoreReason , ...]:
1213+ if not risk_score_reasons :
1214+ return ()
1215+ return tuple (RiskScoreReason (x ) for x in risk_score_reasons ) # type: ignore
1216+
1217+
10781218@_inflate_to_namedtuple
10791219class Factors :
10801220 """Model for Factors response.
@@ -1188,6 +1328,17 @@ class Factors:
11881328 A :class:`.Subscores` object containing scores for many of the
11891329 individual risk factors that are used to calculate the overall risk
11901330 score.
1331+
1332+ .. attribute:: risk_score_reasons
1333+
1334+ This tuple contains :class:`.RiskScoreReason` objects that describe
1335+ risk score reasons for a given transaction that change the risk score
1336+ significantly. Risk score reasons are usually only returned for medium to
1337+ high risk transactions. If there were no significant changes to the risk
1338+ score due to these reasons, then this tuple will be empty.
1339+
1340+ :type: tuple[RiskScoreReason]
1341+
11911342 """
11921343
11931344 billing_address : BillingAddress
@@ -1205,6 +1356,7 @@ class Factors:
12051356 shipping_phone : Phone
12061357 subscores : Subscores
12071358 warnings : Tuple [ServiceWarning , ...]
1359+ risk_score_reasons : Tuple [RiskScoreReason , ...]
12081360
12091361 __slots__ = ()
12101362 _fields = {
@@ -1223,6 +1375,7 @@ class Factors:
12231375 "shipping_phone" : Phone ,
12241376 "subscores" : Subscores ,
12251377 "warnings" : _create_warnings ,
1378+ "risk_score_reasons" : _create_risk_score_reasons ,
12261379 }
12271380
12281381
0 commit comments