Test your risk rules
Verify that payment, cancel, review, and action rules fire correctly by creating test charges and inspecting the response.
Pay.com's rules engine evaluates conditions on each incoming charge and applies a configured action before or after authorization. Rules are created in the Pay.com dashboard, not via the API. To test a rule, send a test charge that triggers it and read the response to confirm the rule fired.
Rule types
Four rule types are available:
| Rule type | When it runs | Available actions |
|---|---|---|
| Payment | Before authorization (pre-network) | Block, 3DS challenge, Require 3DS, 3DS not required, 3DS exemption |
| Cancel | After authorization, before settlement | Void the hold, direct charge, or 3DS charge |
| Review | After authorization (post-network) | Flag transaction for review, Flag customer for review |
| Action | After the payment completes | Add payment values to your risk lists |
Requirements
To test a rule, you need:
- A rule created and Enabled in the Pay.com dashboard. Disabled rules have no effect.
- Simulation Mode turned off if you want the rule to enforce its action.
In simulation mode, the rule doesn't change the payment decision, and
matched simulated rules appear in
risk_assessment_details.simulated. - A sandbox key enabled for raw card data, because the test charges send card details. See PCI compliant keys.
- A raw card charge that includes the field the rule evaluates.
Fields the rules engine evaluates
When creating a charge, set the field your rule's condition reads to a value that matches it. These fields are the easiest to set in a test:
| Rule field | What the rule reads | Where to set it in the request |
|---|---|---|
| First name | The customer's first name | source_data.billing_details.name |
| Card BIN | First six digits of the card number | source_data.card.number (derived automatically) |
| Card country | Issuing country of the card, from the card's BIN | Derived from source_data.card.number. Use a card issued in the target country. |
| Metadata | A key in metadata | metadata |
See Rule conditions and operators for every field.
Test a payment rule
Payment rules run synchronously before the charge reaches the card network.
The result is visible in the immediate charge response under
risk_assessment_details.
- 1
Create a charge that matches the rule condition
Send a
POSTrequest to/v1/charges. Set the condition field inbilling_detailsto a value that matches your rule. Amounts are in the currency's smallest unit, so1000is $10.00 USD.For a rule that requires 3DS, include
authentication_contextwith browser details inside thecardobject. Without it, the 3DS flow can't complete.This example tests a payment rule with the condition
first name equals TestThreeDS:{ "amount": 1000, "currency": "usd", "source_data": { "type": "card", "card": { "number": "4242424242424242", "expiry_month": "12", "expiry_year": "2028", "cvv": "123", "name": "TestThreeDS User", "authentication_context": { "customer_ip_address": "203.0.113.10", "browser_details": { "accept_header": "*/*", "javascript_enabled": true, "language": "en-US", "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64)", "screen_width": 1920, "screen_height": 1080, "timezone_offset": "-300", "java_enabled": false, "color_depth": 24 } } }, "billing_details": { "name": "TestThreeDS User", "email": "test@example.com", "address": { "line1": "100 Test St", "city": "New York", "state": "NY", "postal_code": "10001", "country": "US" } } }, "payment_method_options": { "card": { "duplicate_card_check": false } }, "description": "Rule test: require 3DS" }{ "id": "chrg_697560860452719616", "status": "succeeded", "risk_assessment_details": { "outcome": "require_three_ds", "outcome_source": "rule", "rule_id": "rl_697532456877686784", "flags": [], "bypassed": [] }, "payment_method_details": { "card": { "three_d_secure": { "authentication_flow": "frictionless", "eci": "05", "liability_shift": true, "result": "success", "result_reason": "authenticated", "version": "2.2.0" } } } } - 2
Confirm the rule fired
Check
risk_assessment_detailsin the response:outcomeshows what action the rule applied (require_three_ds,block, and so on).outcome_source: "rule"confirms a dashboard rule triggered the action rather than the card network or issuer.rule_idis the ID of the matched rule, matching the ID in the Pay.com dashboard.
If
risk_assessment_detailsisnull, the rule didn't fire. See Troubleshooting.
Require 3DS outcome
When a payment rule requires 3DS, Pay.com authenticates the customer before authorization. The response depends on how the issuer handles authentication:
- Frictionless: The issuer authenticates the customer without a browser
redirect. The charge completes in one request with
status: "succeeded"andpayment_method_details.card.three_d_secure.authentication_flow: "frictionless", as shown in the response above. - Browser challenge: The issuer requires an interactive step. The charge
returns
status: "requires_authentication". Continue with the 3DS challenge flow to create a linked authentication session and redirect the customer.
Block outcome
When a payment rule blocks a charge, it fails before reaching the card network.
The API returns an error with code: "card_declined",
decline_code: "blocked_by_risk_rule", risk_assessment_details.outcome: "block",
and underlying_network_details: null. The charge object is still created and
retrievable via
GET /v1/charges/{charge_id}
using error.charge. See
Blocked payments
for the full error payload and all block decline codes.
Review outcome
Review rules run asynchronously after authorization and flag the transaction
or customer without blocking the payment, so the charge returns
status: "succeeded". To confirm a review rule fired, wait for the
review.transaction.created or review.customer.created webhook event, or
poll for reviews a few seconds later:
GET /v1/risk/review/reference/chrg_697560887862495232The response is a list ("resource": "reviews"). An empty data array means
no review was created. Flagged items also appear under Risk Reviews in the
Pay.com dashboard. See Review rules and
Risk reviews.
Cancel outcome
Cancel rules run after the card network authorizes a hold, direct charge (where
supported by the acquirer), or 3DS charge at confirmation. The API returns an
error with decline_code: "cancelled_by_risk" and a populated
underlying_network_details containing an auth_code (confirming the
authorization succeeded before the void). Retrieve the failed hold or charge
using error.hold or error.charge to inspect
risk_assessment_details.rule_id and failure_message. See
Cancel rules for complete
request, error, and retrieved record payloads.
Action outcome
Action rules run asynchronously after the payment completes and never alter the charge response. To verify an action rule fired, open the target list in Rules → Risk Lists in the Pay.com dashboard and confirm the payment's value appears with the rule name in the Added by column. See Action rules.
Troubleshooting
Most test failures come from a dashboard configuration setting rather than the API request. Check these two causes first.
risk_assessment_details is null in the response
Verify these rule settings in the Pay.com dashboard before changing your request:
- Rule status: Go to Rules and confirm the rule is Enabled. Disabled rules have no effect.
- Simulation mode: Confirm Simulation Mode is turned off if you
expect the rule to change the payment outcome. In simulation mode, the
payment decision doesn't change, and matched simulated rules appear in
risk_assessment_details.simulated. - Off-session charges: A payment rule skips charges with
off_session: trueunless Evaluate in recurring transactions is enabled on the rule. Turn it on, or test with a raw card charge withoutoff_session.
decline_code: duplicate_card instead of rule outcome
If your sandbox account has duplicate card checking enabled, reusing an already
tokenized card returns decline_code: duplicate_card before the rules engine
runs. Pass "duplicate_card_check": false in payment_method_options.card
when testing in the sandbox, as shown in the example above.
Next steps
- Payment rules: Configure pre-authorization actions including Block, 3DS challenge, Require 3DS, and 3DS exemptions.
- Review rules: Configure post-authorization flagging for transactions and customers.
- Test risk events: Simulate disputes, collaborations, and fraud warnings in the sandbox.
- 3D Secure: Handle
requires_authenticationresponses when a rule triggers a browser challenge. - Webhook events: Subscribe to charge and review events.
- Verify webhook signatures: Confirm each event came from Pay.com.