# Routing Conditions

A condition matches against an attribute of the incoming payment.

```jsonc
{
  "condition_type": "<ENUM>",
  "conditional":    "<OPERATOR>",
  "values":         ["..."],

  // Required only on specific condition_types — see "Special cases" below
  "key":      "<string>",   // METADATA only
  "currency": "<ISO 4217>"  // AMOUNT only
}
```

Conditions inside the same `condition_sets[].conditions[]` are combined with **logical AND**. For OR semantics, split into multiple condition sets ordered by `sort_number`.

#### `condition_type` catalog

| `condition_type` | Matches against | Value shape | Applicable `conditional`s | Card-only? |
|---|---|---|---|---|
| `COUNTRY` | Transaction country — the top-level `country` field you submit in `POST /v1/payments` (never the card) | ISO 3166-1 alpha-2 (e.g. `"US"`, `"BR"`) | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | no |
| `CARD_ISSUER_COUNTRY` | Card-issuing bank's country, resolved by WHITELABEL's BIN lookup at processing time | ISO 3166-1 alpha-2 | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | yes |
| `AMOUNT` | Transaction amount. Sent as `AMOUNT` with a sibling `currency` field; WHITELABEL stores it internally as `CURRENCY_AND_AMOUNT` | Decimal as **string** (e.g. `"100.00"`); requires sibling `currency` | `EQUAL`, `NOT_EQUAL`, `GREATER_THAN`, `LESS_THAN`, `BETWEEN`, `NOT_BETWEEN` | no |
| `CARD_TYPE` | Card funding source | `CREDIT`, `DEBIT`, `PREPAID` | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | yes |
| `CARD_BRAND` | Card scheme | `VISA`, `MASTERCARD`, `AMEX`, `ELO`, `HIPERCARD`, `DINERS`, `DISCOVER`, `JCB`, `UNIONPAY`, `MAESTRO`, `CB` | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | yes |
| `CARD_BIN` | First 6–8 digits of the PAN | 6–8 digit numeric string | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | yes |
| `TRANSACTION_TYPE` | Payment intent type | `PURCHASE`, `AUTHORIZATION`, `RECURRING`, `MIT`, `CIT` | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | no |
| `METADATA` | `payment.metadata[<key>]` | Any string the merchant sets; requires sibling `key` | `EQUAL`, `NOT_EQUAL`, `ONE_OF`, `NOT_ONE_OF` | no |

<Warning>
`CURRENCY` and `INSTALLMENTS` are **not** valid standalone `condition_type` values. Sending either one rejects the whole routing with `400 INVALID_ROUTE_CONFIGURATION`. To filter by currency, use `AMOUNT` with the sibling `currency` field.
</Warning>

#### `conditional` operators

| Operator | Cardinality of `values[]` | Semantics |
|---|---|---|
| `EQUAL` | exactly 1 | `attribute == values[0]` |
| `NOT_EQUAL` | exactly 1 | `attribute != values[0]` |
| `ONE_OF` | ≥ 1 | `attribute ∈ values` |
| `NOT_ONE_OF` | ≥ 1 | `attribute ∉ values` |
| `GREATER_THAN` | exactly 1 | numeric `attribute > values[0]` |
| `LESS_THAN` | exactly 1 | numeric `attribute < values[0]` |
| `BETWEEN` | exactly 2 | inclusive on both ends |
| `NOT_BETWEEN` | exactly 2 | inverse of `BETWEEN` |

#### Special cases

- **`AMOUNT` requires `currency`.** Comparisons are FX-naive; only payments whose currency matches the rule's `currency` are evaluated.
- **`METADATA` requires `key`.** Compares `payment.metadata[key]`. If the key is absent on the payment, the condition does **not** match — absence is not equality.
- **Card-only condition types** (`CARD_ISSUER_COUNTRY`, `CARD_TYPE`, `CARD_BRAND`, `CARD_BIN`) are only valid when `payment_method = "CARD"`.
- **`COUNTRY` vs `CARD_ISSUER_COUNTRY`.** The two are sourced independently: `COUNTRY` matches the transaction country your backend submits in the payment request, while `CARD_ISSUER_COUNTRY` matches the issuer country WHITELABEL's own BIN lookup derives from the card number. The same payment can be `COUNTRY = US` and `CARD_ISSUER_COUNTRY = GB` at once. The BIN lookup runs before a provider is selected, is identical in sandbox and production, and reflects real-world BIN-registry data — never the processor's view of the card.
- **Numeric values are submitted as strings** to match the `values: string[]` schema. WHITELABEL parses them based on the `condition_type`.

#### Testing `CARD_ISSUER_COUNTRY` rules in sandbox

<Warning>
**Provider test-card countries are simulator metadata**

The "country" a payment provider documents for its test cards exists only inside that provider's own test environment — it is simulator metadata attached to the PAN, not a property of the number itself. WHITELABEL's BIN lookup resolves the real-world registry entry instead, so a test card's documented country and its resolved `card_data.country_code` in WHITELABEL usually differ.
</Warning>

Two examples with Stripe's test cards:

| Test card | Documented by the provider as | Resolves in WHITELABEL as | Why |
|---|---|---|---|
| `4242 4242 4242 4242` | US | `GB` (issuer: Stripe Payments UK) | BIN `424242` is registered to Stripe Payments UK Ltd in the actual Visa registry |
| `4000 0019 6000 0008` | Cyprus | `US` | Any `4000 00...` Stripe test card resolves the same `400000` registry record, which is a US-registered range, regardless of the country the last digits encode |

To verify a `CARD_ISSUER_COUNTRY` rule end-to-end today, work with resolved values rather than documented ones — the lookup is deterministic:

1. Run one sandbox payment with a candidate test card.
2. Read `card_data.country_code` from the payment (payment details in the dashboard, or the [Retrieve Payment](/reference/payments/retrieve-payment-by-id) response).
3. Build the rule against that value. For example, `4242 4242 4242 4242` is a dependable `GB` card end-to-end.

The same caveat applies to every BIN-derived condition (`CARD_TYPE`, `CARD_BRAND`), though country is where provider test-card documentation diverges most often.