Worldpay.FraudSight (Worldpay v1.0.0)

Copy Markdown View Source

Worldpay FraudSight API — ML-based fraud risk assessment and SCA exemptions.

Can be used standalone before a card payment, or embedded directly in Card Payments / Payments API orchestrated calls.

Standalone usage

{:ok, assessment} = Worldpay.FraudSight.assess(%{
  "transactionReference" => "order-123",
  "merchant" => %{"entity" => "default"},
  "instruction" => %{
    "value" => %{"amount" => 1999, "currency" => "GBP"},
    "paymentInstrument" => %{"type" => "card/plain", ...}
  },
  "customer" => %{
    "ipAddress" => "1.2.3.4",
    "email" => "user@example.com"
  }
}, config)

# assessment["outcome"] => "notHighRisk" | "highRisk"

Attach to card payment

Take the riskProfile href from the assessment response and include it in the Card Payments authorize instruction:

risk_href = get_in(assessment, ["_links", "fraudsight:riskProfile", "href"])

instruction = %{
  ...
  "instruction" => %{
    ...
    "riskProfile" => %{"href" => risk_href}
  }
}

SCA exemption (TRA)

Include "exemption" => %{"type" => "TRA"} in the assessment body to request a Transaction Risk Assessment exemption at the same time.

Summary

Functions

Request a fraud risk assessment (and optionally an SCA exemption).

Assess and return only the risk profile href for embedding in a payment.

Update the fraud model with the actual payment outcome.

Functions

assess(body, config)

@spec assess(map(), Worldpay.Config.t()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}

Request a fraud risk assessment (and optionally an SCA exemption).

assess_and_extract_href(body, config)

@spec assess_and_extract_href(map(), Worldpay.Config.t()) ::
  {:ok, String.t()} | {:error, :high_risk | Worldpay.Error.t()}

Assess and return only the risk profile href for embedding in a payment.

Returns {:ok, href} when outcome is "notHighRisk", {:error, :high_risk} when outcome is "highRisk".

update_outcome(assessment_id, body, config)

@spec update_outcome(String.t(), map(), Worldpay.Config.t()) ::
  {:ok, map()} | {:error, Worldpay.Error.t()}

Update the fraud model with the actual payment outcome.

Required when using a 3rd-party gateway alongside FraudSight. Worldpay uses this data to improve the ML model.

Body fields

  • "transactionAuthorized" — boolean
  • "fraudReported" — boolean
  • "fraudType""TC40" | "SAFE" | nil