Skip to Content
Docs

Cancel rules

Automatically void authorized transactions that meet conditions you define, before the payment settles.

Cancel rules let you automatically void transactions after the card network authorizes them but before settlement. When a transaction matches a cancel rule's conditions, Pay.com voids the authorization and returns a configurable failure message.

How cancel rules differ from payment rules

Payment rules fire before authorization, so the charge never reaches the card network. Cancel rules fire after authorization. The card network approves the funds first, and then Pay.com voids the authorization.

Payment rule (Block)Cancel rule
FiresBefore the card networkAfter the card network authorizes
underlying_network_detailsnull (charge never sent)Populated (authorization occurred)
decline_codeblocked_by_risk_rulecancelled_by_risk
Applies toCharges, holdsCharges, holds

Use a cancel rule when the condition you want to evaluate is only meaningful after an authorization has been issued. Use a payment rule with the Block action if you want to prevent the charge from reaching the card network entirely.

When cancel rules fire

Cancel rules evaluate after authorization. The exact moment depends on the transaction type:

Transaction typeWhen the cancel rule fires
HoldAt POST /v1/holds, after the card network authorizes the hold
Direct chargeAt POST /v1/charges, after authorization but before capture
Charge with 3D SecureAt POST /v1/charges/{id}/confirm, after the customer completes the 3DS challenge

For direct charges, Pay.com processes authorization and capture as two internal steps. The cancel rule runs between them. Neither you nor your customer sees this intermediate state.

Cancel rules on direct charges depend on acquirer support. Not all acquirers support post-authorization voids on direct charges. Contact your Pay.com account team to confirm this is available for your integration.

Cancel rules also apply to off-session charges and holds, created with off_session: true. Unlike payment rules, they have no setting to skip these recurring transactions.

Conditions

Cancel rules evaluate the same fields as payment rules, plus the results the card network returns: the AVS and CVV checks, the 3D Secure result, and the Account Name Inquiry result. They can also read Matched payment rule. For each condition, choose a Field, an Operator, and a Value. For the complete list of fields and operators, see Rule conditions and operators.

The cancel rules page

Go to Rules → Cancel in the Pay.com dashboard to access cancel rules. The page has three tabs:

  • Rules: lists all your cancel rules. Each rule shows its current state (Enabled or Disabled). From here you can toggle a rule on or off, open it, or edit, duplicate, or delete it.
  • Logs: shows the transactions your cancel rules evaluated, and whether each rule matched.
  • Audit Log: shows who created, changed, or deleted each rule.

Like payment rules, cancel rules have a Simulation Mode, which logs matches without voiding the transaction.

Create a cancel rule

Create the rule in the Pay.com dashboard's rule builder. It's enabled as soon as you save it.

  1. 1

    Open the rule builder

    In Rules → Cancel, click Create new rule.

    Give the rule a descriptive name so you can identify it later.

  2. 2

    Configure the logic

    Define the conditions the rule evaluates on each transaction. For each condition, choose a Field, an Operator, and a Value.

    You can combine multiple conditions using AND (all conditions must be true) or OR (any condition must be true).

    To match against a set of values, choose the is in list operator and select a risk list you've already created.

  3. 3

    Set the failure message

    Enter the message returned in failure_message when the rule cancels a transaction. This message appears on the hold or charge record and is visible to you via the API.

  4. 4

    Save the rule

    Click Confirm & Save Rule. The rule is enabled immediately.

Cancel rule outcome

When a cancel rule matches, the API returns an error response with decline_code: "cancelled_by_risk". The hold or charge object is still created with status: "failed". Retrieve it with the ID in the error object to inspect the full record, including risk_assessment_details.

Hold canceled by a rule

In this example, a rule with the condition first name equals TestCancel cancels a hold. Amounts are in the currency's smallest unit, so 1000 is $10.00 USD. The request sends raw card details, which require an API key enabled for raw card data. See PCI compliant keys.

{
  "amount": 1000,
  "currency": "usd",
  "source_data": {
    "type": "card",
    "card": {
      "number": "4242424242424242",
      "expiry_month": "12",
      "expiry_year": "2028",
      "cvv": "123",
      "name": "TestCancel User"
    },
    "billing_details": {
      "name": "TestCancel User",
      "email": "customer@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": "Hold with cancel rule condition"
}

The hold object is still created. Retrieve it with the ID in error.hold:

GET /v1/holds/hld_701530028785011712

Direct charge canceled by a rule

Direct charges created with POST /v1/charges follow the same structure, with two differences:

  • The error response returns error.charge (such as "chrg_701530061018236928") instead of error.hold.
  • Retrieve the failed charge record from GET /v1/charges/{charge_id} to read failure_code, failure_message, risk_assessment_details, and underlying_network_details.

On any canceled hold or charge:

  • underlying_network_details is populated and includes an auth_code. The authorization reached the card network and was approved before the cancel rule voided it.
  • risk_assessment_details contains outcome_source: "rule" and the rule_id of the matched rule. Unlike payment rule outcomes, there is no outcome field.
  • The hold or charge object is still created and retrievable. Use the ID in error.hold or error.charge to fetch it.

Next steps

  • Payment rules: Block charges or enforce 3DS before they reach the card network.
  • Review rules: Flag transactions or customers for manual review after authorization.
  • Risk lists: Create named collections of values to use in rule conditions.
  • Test your rules: Verify that rules fire correctly using test transactions.
Was this page helpful?