Overview

Legacy Warning

As of July, 2016 Formulas and Actions are a legacy option for automating fraud decisions with Sift. If you are a Sift customer that is already using Formulas, they will continue working as expected, but we encourage you to check out our new suite of automation tools - Workflows!

Formulas make it easy to code logic like this into your application:

This guide will help you use Formulas to automate fraud decision making. While this guide is written for e-commerce businesses fighting chargebacks, you can use the underlying principles of these instructions to stop other kinds of fraud.

Before You Start

Please review the Chargebacks Integration Guide. Prior to using Formulas, you’ll need to follow the first two sections of the guide, which outline how to install our JavaScript snippet and send event data to us.

There are four sections in this document:

  1. Identify decision points in a checkout flow
  2. Register Actions
  3. Use Formulas to specify when to Hold or Accept orders
  4. Use Actions to make decisions in your checkout flow

Identify decision points in the checkout flow

Developer Task: Identify Decision Points

  • Understand decisions you can make during a checkout flow to prevent chargebacks
  • Identify the point in a checkout flow to accept, hold or reject an order

There are typically five steps in a checkout flow:

To prevent chargebacks, most merchants need to decide whether to fulfill an order after an order has been accepted and paid for. There are three typical actions a merchant can take at this decision point: fulfill an order, hold an order for further review or automatically reject an order.

With Formulas, you can set up criteria that specifies when to accept, review or reject orders. Then, using Actions, you can ask Sift during a checkout flow which decision to take.

Register Actions

Developer Task: Create Actions

Setup Actions named Hold and Fulfill in the Sift Console

Now we know we want to either hold an order for review or fulfill an order following processing payment, let’s register these Actions with Sift.

First, let’s log into the Sift console. Click on the Actions tab on the left hand side.

We want to create two Actions - Hold and Fulfill. Let’s create Hold first:

Now, create an Action named Fulfill the same way.

You’ll want to note the Action ID listed for each Action - you’ll need these to identify which Action to take during a checkout flow.

Use Formulas to specify when to Hold or Accept orders

Developer Task: Create Formulas

In the Sift console, create Formulas that identify Suspicious and Legitimate users, then attach the Hold and Fulfill Actions to those Formulas, respectively.

Now we’ve defined two Actions named Hold and Fulfill, let’s specify when those Actions are applied. Let’s say your fraud team has decided that you want to Hold orders when:

  • The Sift Score is above 60
  • A customer has been labelled bad in the past
  • The country the user placed an order from is outside the US

Let’s create a Formula to identify users we find suspicious, then specify that we want to apply the Hold Action for those users.

First, go to Lists.

Create a List named Suspicious Users with criteria that identify suspicious users:

As an example, we will set the List to include all users with a score greater than or equal to 60, and the Country is not US:

Let’s create a Formula from this List.

Last, let’s specify that we want to apply the Hold action when any of the criteria we specified are true:

Repeat the same steps to create a Formula that identifies Legitimate Users, and attach the Fulfill action to that Formula.

Use Actions to make decisions in your checkout flow

Developer Task: Start Coding!!

Implement code that will call the Actions API.

Let’s assume we want to determine whether to fulfill an order following payment processing. You would do the following to accomplish this:

  • After processing payment, send a $transaction event to Sift
  • When POST-ing the $transaction event, append the parameter return_action=true to the URL. If you’re using a client library, set the return_action parameter to true in the track method
  • Determine whether the Action ID for Hold in the actions paragraph in the response body
  • If so, hold the order
  • If not, fulfill the order

This pseudo-code outlines this process:

# Action IDs are available in the Sift Console
HOLD_ACTION = "557105732e1d36caeaa8d74e"
FULFILL_ACTION = "557105ee2e1d36caeaa8d74f"

def handle_checkout(order):
  # Send Sift data related to this order
  sift_client.track(“$create_order”, order, return_action=True)

  transaction = process_payment()

  # Send Sift data related to the transaction 
  # and ask for what Actions to take
  response = sift_client.track("$transaction", transaction, return_action=True)

  # Parse the response body and determine
  # whether the HOLD_ACTION was returned -
  # if so, hold the order
  action_ids = [action["id"] for action in response["actions"]]
  if HOLD_ORDER in action_ids:
    hold_order()

  # Else, fulfill the order
  fulfill_order()

The response you should expect back looks like this:

{
  "user_id": "a_user_id",
  "score": 0.93,
  "actions":  [ // Array of Actions that currently apply to this User
       {
          "id": "557105732e1d36caeaa8d74e",
          "ref": "https://api3.siftscience.com/v3/accounts/<account_id>/actions/557105732e1d36caeaa8d74e"
       }
  ]
}

If you’re using Formulas to manage a whitelist in which you fulfill orders from certain users regardless of how suspicious they behave, you might want to adjust the process above to check for the Fulfill Action prior to checking for the Hold Action. For example:

action_ids = [action["id"] for action in response["actions"]]
if FULFILL_ORDER in action_ids:
  fulfill_order()
elif HOLD_ORDER in action_ids:
  hold_order()

Conclusion

Congratulations! Now you know how to use Actions to automate fraud decision making. To summarize, the process to integrate Actions is:

  1. Follow the first two steps of the e-commerce Integration, and ensure you’ve installed our JavaScript snippet and have started sending us, at the very least, order and transaction data
  2. Identify decisions and decision points in key flows on your site. For example, understand whether you want to hold orders for manual review after completing payment processing
  3. Register Actions in the Sift Console. Actions are business decisions you want to make, like Hold or Fulfill orders
  4. Setup Formulas in the Sift Console that specify when you should take certain Actions
  5. Integrate Actions into key flows like your checkout flow