Skip to content

Commit c78a2cc

Browse files
Add score percentiles example
1 parent f5d06ef commit c78a2cc

1 file changed

Lines changed: 27 additions & 0 deletions

File tree

README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,33 @@ except sift.client.ApiException:
9292
# request failed
9393
pass
9494

95+
# Track a transaсtion event and receive a score with percentiles in response (sync flow).
96+
# Note: `return_score` or `return_workflow_status` must be set `True`.
97+
properties = {
98+
"$user_id": user_id,
99+
"$user_email": "buyer@gmail.com",
100+
"$seller_user_id": "2371",
101+
"seller_user_email": "seller@gmail.com",
102+
"$transaction_id": "573050",
103+
"$payment_method": {
104+
"$payment_type": "$credit_card",
105+
"$payment_gateway": "$braintree",
106+
"$card_bin": "542486",
107+
"$card_last4": "4444"
108+
},
109+
"$currency_code": "USD",
110+
"$amount": 15230000,
111+
}
112+
113+
try:
114+
response = client.track("$transaction", properties, return_score=True, include_score_percentiles=True, abuse_types=["promotion_abuse", "content_abuse", "payment_abuse"])
115+
if response.is_ok():
116+
score_response = response.body["score_response"]
117+
print(score_response)
118+
except sift.client.ApiException:
119+
# request failed
120+
pass
121+
95122
# Request a score for the user with user_id 23056
96123
try:
97124
response = client.score(user_id)

0 commit comments

Comments
 (0)