> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Riskified

Payment card fraud losses worldwide exceeded \$32 billion in 2021 and will continue to rise.
Protect your bottom line by deploying a fraud service, like Riskified, to stop bad actors from making it through your checkout

<Note>
  See our [Fraud Overview](/payment-services/fraud-checks/overview) for more general information about how we support fraud prevention.
</Note>

## What is supported?

### Resulting decisions

* `Pass`
* `3DS`
* `Reject`
* `Fail`

### Payment methods

* Card
* Apple Pay
* Google Pay
* PayPal

### Fraud check flows

Riskified performs its main fraud check with an endpoint named `Decide`. Depending on your use case and fraud profile, Riskified will suggest you to leverage `Decide` either before or after the authorization. This is defined when Riskified creates your account and configures your fraud prevention model.

When connecting Primer to your Riskified account, make sure to specify when `Decide` should be called - either before or after the authorization.

<Note>
  **`Decide` before the authorization**

  In this flow, the main fraud check happens at pre-authorization.

  * *Pre-authorization check* <br /> We ask Riskified to `Decide` whether we should proceed with the authorization. *(3DS is currently not supported)*
  * *Post-authorization check* <br /> We do no send anything to Riskified. This check fails immediately.

  Riskified expects to receive a notification after the authorization. This can be done in the workflow by

  * calling the action `Decision` when the payment is successfully authorized
  * calling the action `Checkout Denied` when the payment is not authorized
</Note>

<Note>
  **`Decide` after the authorization**

  In this flow, the main fraud check happens after the payment is sent to the processor.

  * *Pre-authorization check* <br /> We ask Riskified to `Advise` if 3DS should be used or not, and whether we should proceed with the authorization.
  * *Post-authorization check* <br /> We ask Riskified to `Decide`, knowing the 3DS result and the authorization outcome, whether to proceed or cancel the payment.

  Riskified expects to receive a notification after the authorization. This can be done in the workflow by

  * calling the action `Checkout Denied` when the payment is not authorized
</Note>

## Instructions

### Set-up Instructions

* Go to your [Primer Dashboard](https://dashboard.primer.io/).
* Navigate to the "Integrations" section, select "Add Integration" at the top of the page and search for **Riskified**. Follow the dashboard instructions. <br /> *Make sure to match "Fraud check flow" with how your Riskified account is configured.*
* Follow the rest of the steps to set up [Primer Workflows for fraud checks](/payment-services/fraud-checks/overview).

### Notifications

You can use [Workflows](/get-started/create-workflow#create-a-workflow) to also notify Riskified for updates that happen after the authorization step:

* If Riskified is configured so that `Decide` is called before the authorization, call the action `Checkout Denied` when the payment is not authorized, and the action `Decision` when the payment is authorized.
* If Riskified is configured so that `Decide` is called before the authorization, call the action `Checkout Denied`
* When a dispute is opened for a payment, call the action `Chargeback`. <br />*See [dispute management](/disputes/overview) for details around processor coverage.*

To do so, connect to the [Workflow App](/workflows/apps/overview) for Riskified and either update your existing payment flows flows, or just apply the pre-configured Riskified [templates](/workflows/templates).

### Testing

#### Pre-authorization fraud check

* To trigger a `Pass` outcome, set `customer.emailAddress` to start with `out_of_scope`.
* To trigger a `Reject` outcome, set `customer.emailAddress` to start with `fraud`.
* To trigger a `3DS` outcome, set `customer.emailAddress` to start with `sca`.
* To trigger a `Fail` outcome you will need to pass a request that is incorrect. An example of this is to set the `currency` to `something` as this field needs to be a recognised currency code.

#### Post-authorization fraud check

* To trigger a `Pass` outcome, set `customer.emailAddress` to equal `test@approve.com`
* To trigger a `Reject` outcome, set `customer.emailAddress` to equal `test@decline.com`

#### General Notes

* You must update the Primer `orderId` for each Riskified test. Reusing the same `orderId` returns a previous result. You can override the fraud order id by providing a `fraudContext.fraudOrderId` inside `metadata`.

## Mapping

### Base mapping

| Riskified                        | Primer                                                                 |
| -------------------------------- | ---------------------------------------------------------------------- |
| `id`                             | `payment.orderId`                                                      |
| `email`                          | `payment.customer.emailAddress`                                        |
| `created_at`                     | Payment creation time                                                  |
| `currency`                       | `payment.currencyCode`                                                 |
| `gateway`                        | Processor or payment method                                            |
| `total_price`                    | `payment.amount`                                                       |
| `cart_token`                     | `payment.metadata.fraud_context.device_details.cookie_token`           |
| `referring_site`                 | `payment.metadata.fraud_context.device_details.referring_site`         |
| `source`                         | `payment.metadata.fraud_context.device_details.source`                 |
| `browser_ip`                     | `payment.metadata.fraud_context.device_details.browser_ip`             |
| `device_id`                      | `payment.metadata.fraud_context.device_details.device_id`              |
| `client_details.user_agent`      | `payment.metadata.fraud_context.device_details.user_agent`             |
| `client_details.accept_language` | `payment.metadata.fraud_context.device_details.accept_language`        |
| `vendor_id`                      | `payment.metadata.fraud_context.merchant_details.merchant_provider_id` |
| `vendor_name`                    | `payment.metadata.fraud_context.merchant_details.merchant_name`        |
| `line_items[].price`             | `payment.order.lineItems[].amount`                                     |
| `line_items[].quantity`          | `payment.order.lineItems[].quantity`                                   |
| `line_items[].title`             | `payment.order.lineItems[].name`                                       |
| `line_items[].brand`             | `payment.order.lineItems[].productData.brand`                          |
| `line_items[].product_type`      | `payment.order.lineItems[].productType`                                |
| `line_items[].sku`               | `payment.order.lineItems[].productData.sku`                            |
| `shipping_lines[0].price`        | `payment.order.shipping.amount`                                        |
| `shipping_lines[0].title`        | `payment.order.shipping.methodName`                                    |
| `customer.id`                    | `payment.customerId`                                                   |
| `customer.email`                 | `payment.customer.emailAddress`                                        |
| `customer.first_name`            | `payment.customer.firstName`                                           |
| `customer.last_name`             | `payment.customer.lastName`                                            |
| `customer.phone`                 | `payment.customer.mobileNumber`                                        |
| `customer.address.first_name`    | `payment.customer.billingAddress.firstName`                            |
| `customer.address.last_name`     | `payment.customer.billingAddress.lastName`                             |
| `customer.address.address1`      | `payment.customer.billingAddress.addressLine1`                         |
| `customer.address.address2`      | `payment.customer.billingAddress.addressLine2`                         |
| `customer.address.country_code`  | `payment.customer.billingAddress.countryCode`                          |
| `customer.address.city`          | `payment.customer.billingAddress.city`                                 |
| `customer.address.zip`           | `payment.customer.billingAddress.postalCode`                           |
| `customer.address.province`      | `payment.customer.billingAddress.state`                                |
| `billing_address.first_name`     | `payment.customer.billingAddress.firstName`                            |
| `billing_address.last_name`      | `payment.customer.billingAddress.lastName`                             |
| `billing_address.address1`       | `payment.customer.billingAddress.addressLine1`                         |
| `billing_address.address2`       | `payment.customer.billingAddress.addressLine2`                         |
| `billing_address.country_code`   | `payment.customer.billingAddress.countryCode`                          |
| `billing_address.city`           | `payment.customer.billingAddress.city`                                 |
| `billing_address.zip`            | `payment.customer.billingAddress.postalCode`                           |
| `billing_address.province`       | `payment.customer.billingAddress.state`                                |
| `shipping_address.first_name`    | `payment.customer.shippingAddress.firstName`                           |
| `shipping_address.last_name`     | `payment.customer.shippingAddress.lastName`                            |
| `shipping_address.address1`      | `payment.customer.shippingAddress.addressLine1`                        |
| `shipping_address.address2`      | `payment.customer.shippingAddress.addressLine2`                        |
| `shipping_address.country_code`  | `payment.customer.shippingAddress.countryCode`                         |
| `shipping_address.city`          | `payment.customer.shippingAddress.city`                                |
| `shipping_address.zip`           | `payment.customer.shippingAddress.postalCode`                          |
| `shipping_address.province`      | `payment.customer.shippingAddress.state`                               |

### Card, Apple Pay & Google Pay

| Riskified                                                  | Primer                                          |
| ---------------------------------------------------------- | ----------------------------------------------- |
| `payment_details[0].cardholder_name`                       | Cardholder name                                 |
| `payment_details[0].credit_card_number`                    | `XXXX-XXXX-XXXX-LAST_4_DIGITS`                  |
| `payment_details[0].credit_card_bin`                       | Card's first 6 digits                           |
| `payment_details[0].credit_card_company`                   | Card network                                    |
| `payment_details[0].authorization_id`                      | Processor transaction ID                        |
| `payment_details[0].authentication_result.eci`             | ECI                                             |
| `payment_details[0].authentication_result.cavv`            | Cryptogram                                      |
| `payment_details[0].authentication_result.liability_shift` | True if `eci` is `02` or `05`. False otherwise. |
| `payment_details[0].avs_result_code`                       | AVS result code                                 |
| `payment_details[0].cvv_result_code`                       | CVV result code                                 |

### PayPal

| Riskified                             | Primer                                  |
| ------------------------------------- | --------------------------------------- |
| `payment_details[0].authorization_id` | PayPal Order ID or Billing Agreement ID |
| `payment_details[0].payment_status`   | PayPal Status                           |
| `payment_details[0].payer_email`      | PayPal email address                    |

### Custom field mapping

You can use [Advanced Metadata Mapper](/payment-services/advanced-metadata-mapper) with Riskified to map any metadata field to Riskified's requests.
