Skip to Content
Docs

Risk assessments

Score a payment before charging it and decide whether to proceed, require 3DS, or block the transaction.

Pay.com's risk engine evaluates every transaction automatically when you process charges through the gateway. The risk assessment API gives you direct access to that same engine before you create a charge. You send the card data, Pay.com runs the engine and returns a risk score and a recommended outcome, and you act on it in your code.

Use the standalone API when you need to make a decision before a charge is created, for example to route a high-risk customer to a different checkout path or to step up to 3DS before you create the charge.

Risk assessments need the risk API turned on for your account. Without it, every /v1/risk/ endpoint returns 403 with code: permission_denied. The score comes from advanced fraud screening, which must also be on for your account. Contact Pay.com support to turn them on.

Request an assessment

Send a POST request to /v1/risk/assessments with the card data and the amount you intend to charge. Amounts are integers in the currency's minor unit (the smallest unit), for example 10000 for $100.00 USD.

These request fields are required:

  • risk_session_id: the device-fingerprinting session ID (up to 255 characters) from device fingerprinting.
  • amount and currency.
  • Exactly one of source_data or payment_method_data.

You can also send shipping, the shipping address, which the score compares with the billing address and the IP address.

An assessment runs advanced fraud screening on the details you send. If your account uses Pay.com rules, your payment rules run on it too. Account Name Inquiry doesn't run on assessments.

The example sends raw card details in source_data.card, which needs an API key enabled for raw card data. See PCI compliant keys.

authentication_context is required inside the card, token, source, and network_token objects. An empty object ({}) is enough. The assessment's card object doesn't accept three_ds or three_ri. Sending either returns 400.

{
  "risk_session_id": "a4f82c91-3e17-4b09-91dc-b2c3dc25f604",
  "amount": 10000,
  "currency": "usd",
  "source_data": {
    "type": "card",
    "card": {
      "number": "4242424242424242",
      "expiry_month": "12",
      "expiry_year": "2028",
      "cvv": "123",
      "name": "John Smith",
      "authentication_context": {}
    },
    "billing_details": {
      "name": "John Smith",
      "email": "john.smith@example.com"
    }
  },
  "options": {
    "risk_score_thresholds": [
      { "start": 0,  "end": 29,  "outcome": "allow" },
      { "start": 30, "end": 59,  "outcome": "require_three_ds" },
      { "start": 60, "end": 79,  "outcome": "three_ds_challenge" },
      { "start": 80, "end": 100, "outcome": "block" }
    ]
  }
}

The endpoint returns 201 Created on success. You can't retrieve an assessment later, so store the response.

Custom score thresholds

The options.risk_score_thresholds field lets you map score ranges to outcomes. Each entry defines a start, an end, and an outcome. Pay.com evaluates the score against your ranges and sets outcome to the matching entry's value.

Your ranges can make your account's default mapping stricter, not looser. For each score, Pay.com uses your range's outcome only if it's at least as strict as the default mapping's outcome. See How the score becomes an outcome.

Your payment rules also run on each assessment. When a rule and the score both produce an outcome, the stricter one applies. For this comparison, allow ranks below all other outcomes, including three_ds_exemption and three_ds_not_required.

start and end are integers from 0 to 100, and all three fields are required. Boundaries are inclusive on both ends. The request fails with 400 unless your ranges follow these rules:

  • Include an allow range.
  • Cover every score from 0 to 100 with no gaps and no overlaps. If one range ends at 29, the next must start at 30.
  • Escalate in severity as the score rises. A lower range can't have a stricter outcome than a higher one. From least to most severe, the order is three_ds_exemption, three_ds_not_required, allow, require_three_ds, three_ds_challenge, and block.

Adjacent, non-overlapping ranges

[
  { "start": 0,  "end": 29,  "outcome": "allow" },
  { "start": 30, "end": 59,  "outcome": "require_three_ds" },
  { "start": 60, "end": 79,  "outcome": "three_ds_challenge" },
  { "start": 80, "end": 100, "outcome": "block" }
]

The valid outcome values are:

OutcomeMeaning
three_ds_exemptionVery low risk. Request an SCA exemption.
three_ds_not_requiredLow risk. Proceed without 3DS.
allowThe transaction looks low risk. Proceed with the charge.
require_three_dsElevated risk. Start 3DS authentication before charging.
three_ds_challengeHigh risk. Start 3DS and expect an interactive challenge.
blockDo not proceed with this transaction.

If you omit options.risk_score_thresholds, the API accepts the request but doesn't map the score to an outcome, so only a matching rule can set one.

Reading the response

The response holds the score, the recommended outcome, and what set that outcome.

FieldTypeDescription
idstringUnique identifier for the assessment (rsk_...).
scoreintegerRisk score from 0 (lowest risk) to 100 (highest risk). Left out when there's no score.
outcomestringRecommended action based on the score and your thresholds. A missing outcome means allow.
outcome_sourcestringWhat determined the outcome. "score" means no rule matched and the score-to-threshold mapping produced the outcome. "rule" means a rule matched and produced the outcome. "rules" means several rules matched.
rule_idstringThe ID of the rule that set the outcome when outcome_source is "rule". Omitted otherwise.
rules_idarrayThe IDs of the rules that set the outcome when outcome_source is "rules". Omitted otherwise.
flagsarraySignals that contributed to the score, for example "ip_outside_us". Empty when no signals were detected. See Flags for every value.
bypassedarrayThe IDs of rules that were skipped for this assessment.
simulatedarrayThe IDs of rules in simulation mode whose conditions matched. They didn't change the outcome.
shippingobjectThe shipping details you sent, if any.
amountintegerThe amount you submitted, in the currency's smallest unit.
currencystringLowercase ISO 4217 currency code.
billing_detailsobjectThe billing address you sent, if you sent billing_details.address.country. Name, email, and phone are not echoed. null when no address was sent.
payment_method_detailsobjectThe payment method type used in the assessment, for example card_token. Card details are not returned.
optionsobjectThe thresholds you submitted. risk_score_thresholds is an empty array when omitted.
test_modebooleantrue if the assessment was created with a sandbox API key.

Acting on the outcome

In standalone mode, you must implement these actions in your code. The Pay.com gateway does not apply them automatically when you use the assessment API. Use the outcome to decide what to do next before creating the charge.

OutcomeWhat to do
allowProceed with POST /v1/charges.
three_ds_exemptionProceed with the charge and request an SCA exemption.
three_ds_not_requiredProceed with POST /v1/charges without 3DS.
require_three_dsAuthenticate the cardholder with standalone 3DS authentication, then pass the session's three_ds results on the charge, in source_data.card.three_ds.
three_ds_challengeStart a 3DS flow and handle the interactive challenge before charging.
blockDo not create the charge. Inform the customer that the transaction was declined.

Next steps

  • Risk reviews: Handle transactions flagged for manual review after a charge succeeds.
  • Rules: Configure payment rules in the dashboard to control which outcomes the engine returns on each assessment.
  • Advanced fraud screening: Review how the fraud score, default threshold mapping, and screening flags work.
  • Risk assessments API reference: View the full endpoint and parameter reference.
Was this page helpful?