@@ -1075,6 +1075,143 @@ 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+ .. attribute:: code
1144+
1145+ This value is a machine-readable code identifying the
1146+ reason.
1147+
1148+ :type: str | None
1149+
1150+ .. attribute:: reason
1151+
1152+ This property provides a human-readable explanation of the
1153+ reason. The text may change at any time and should not be matched
1154+ against.
1155+
1156+ :type: str | None
1157+ """
1158+
1159+ code : Optional [str ]
1160+ reason : Optional [str ]
1161+
1162+ __slots__ = ()
1163+ _fields = {
1164+ "code" : None ,
1165+ "reason" : None ,
1166+ }
1167+
1168+
1169+ def _create_reasons (reasons : Optional [List [Dict [str , str ]]]) -> Tuple [Reason , ...]:
1170+ if not reasons :
1171+ return ()
1172+ return tuple (Reason (x ) for x in reasons ) # type: ignore
1173+
1174+
1175+ @_inflate_to_namedtuple
1176+ class RiskScoreReason :
1177+ """The risk score multiplier and the reasons for that multiplier.
1178+
1179+ .. attribute:: multiplier
1180+
1181+ The factor by which the risk score is increased (if the value is greater than 1)
1182+ or decreased (if the value is less than 1) for given risk reason(s).
1183+ Multipliers greater than 1.5 and less than 0.66 are considered significant
1184+ and lead to risk reason(s) being present.
1185+
1186+ :type: float | None
1187+
1188+ .. attribute:: reasons
1189+
1190+ This tuple contains :class:`.Reason` objects that describe
1191+ one of the reasons for the multiplier.
1192+
1193+ :type: tuple[Reason]
1194+
1195+ """
1196+
1197+ multiplier : float
1198+ reasons : Tuple [Reason , ...]
1199+
1200+ __slots__ = ()
1201+ _fields = {
1202+ "multiplier" : None ,
1203+ "reasons" : _create_reasons ,
1204+ }
1205+
1206+
1207+ def _create_risk_score_reasons (
1208+ risk_score_reasons : Optional [List [Dict [str , str ]]]
1209+ ) -> Tuple [RiskScoreReason , ...]:
1210+ if not risk_score_reasons :
1211+ return ()
1212+ return tuple (RiskScoreReason (x ) for x in risk_score_reasons ) # type: ignore
1213+
1214+
10781215@_inflate_to_namedtuple
10791216class Factors :
10801217 """Model for Factors response.
@@ -1188,6 +1325,18 @@ class Factors:
11881325 A :class:`.Subscores` object containing scores for many of the
11891326 individual risk factors that are used to calculate the overall risk
11901327 score.
1328+
1329+ .. attribute:: risk_score_reasons
1330+
1331+ This tuple contains :class:`.RiskScoreReason` objects that describe
1332+ risk score reasons for a given transaction
1333+ that change the risk score significantly.
1334+ Risk score reasons are usually only returned for medium to
1335+ high risk transactions. If there were no significant changes to the risk
1336+ score due to these reasons, then this tuple will be empty.
1337+
1338+ :type: tuple[RiskScoreReason]
1339+
11911340 """
11921341
11931342 billing_address : BillingAddress
@@ -1205,6 +1354,7 @@ class Factors:
12051354 shipping_phone : Phone
12061355 subscores : Subscores
12071356 warnings : Tuple [ServiceWarning , ...]
1357+ risk_score_reasons : Tuple [RiskScoreReason , ...]
12081358
12091359 __slots__ = ()
12101360 _fields = {
@@ -1223,6 +1373,7 @@ class Factors:
12231373 "shipping_phone" : Phone ,
12241374 "subscores" : Subscores ,
12251375 "warnings" : _create_warnings ,
1376+ "risk_score_reasons" : _create_risk_score_reasons ,
12261377 }
12271378
12281379
0 commit comments