# Quickstart

> Turn Shield on, set thresholds that hold, and work the review queue.

Shield is already scoring your live payments at the platform thresholds. Turning it on is how you
replace those with your own and unlock everything that acts on a score rather than just reporting
it.

Five steps, all of them in live mode.

> [!WARNING]
> **There is nothing to try first**
>
> Shield enforces nothing in sandbox, sandbox scoring never affects live payers, and the Shield
> endpoints refuse a test key. Whatever you set here takes effect on real customers on the next
> payment. This is why the thresholds have floors and why the sensible order is to activate,
> watch, then tighten.

## 1. Turn it on

In the Dashboard, **Shield** shows an activation screen until you activate it. Activating sets
nothing else: you start on the platform thresholds that were already applying, and
`GET /shield/settings` returns them.

From the API it is one call.

```bash title="Activate Shield"
curl -X PUT https://api.wajub.com/shield/settings \
  -H "Authorization: sk.xxxxxxxxxxxxxxxx…" \
  -H "Content-Type: application/json" \
  -d '{ "enabled": true }'
```

The response returns the settings as they now stand, including an `advanced` flag telling you
whether rules, lists and automatic 3D Secure are available to you.

## 2. Set thresholds that are actually accepted

Both thresholds are bounded, and a value outside the bounds is either refused or quietly brought
back inside. This is the part that surprises people.

| Field              | Accepted                   | What happens outside it                                                  |
| ------------------ | -------------------------- | ------------------------------------------------------------------------ |
| `block_threshold`  | 40 to 100                  | Below 40 or above 100, the request is rejected                           |
| `block_threshold`  | Never above the platform's | A value above the platform's block threshold is brought down to it       |
| `review_threshold` | 10 to 99                   | Below 10 or above 99, the request is rejected                            |
| `review_threshold` | Always below block         | A value at or above your block threshold is brought down to one under it |

So a request asking for a block threshold above the platform's succeeds, and leaves you on the
platform's. Read the settings back after writing them rather than assuming what you sent is what
applies.

```bash title="Set your own thresholds"
curl -X PUT https://api.wajub.com/shield/settings \
  -H "Authorization: sk.xxxxxxxxxxxxxxxx…" \
  -H "Content-Type: application/json" \
  -d '{
    "enabled": true,
    "block_threshold": 70,
    "review_threshold": 45,
    "auto_3ds_enabled": true,
    "blocklist_enabled": true
  }'
```

`auto_3ds_enabled` and `blocklist_enabled` are stored on any plan and only take effect while you
hold Shield Advanced. A stored `true` on a plan without it reads back as `false`.

> [!TIP]
> **Why 40 is the floor**
>
> A block threshold that is too low refuses ordinary new customers. Start at the default, look at
> what got flagged, and adjust from there.

## 3. Read what it decided

Not from the API. The payment response carries no score, and no webhook fires on a Shield
decision. Everything is in the Dashboard.

| Where                | What it holds                                                                 |
| -------------------- | ----------------------------------------------------------------------------- |
| **Shield**, overview | This month's blocked, flagged and reviewed counts, and the split between them |
| **Shield**, reviews  | The queue of flagged payments waiting on you                                  |
| The payment itself   | Its score and the flag codes that produced it                                 |

## 4. Work the review queue

The queue holds every flagged payment from the last 90 days that you have not yet closed, newest
first, twenty to a page. Each row carries the score, the flag codes, the customer and what a full
refund would return.

It also holds the attempts Shield blocked. Those collected nothing, so there is nothing to refund on
them. What you can do is let the customer through next time.

Closing a row takes one of four decisions.

| Decision              | What it does                                                                          |
| --------------------- | ------------------------------------------------------------------------------------- |
| Approve               | Marks it reviewed. Nothing else changes                                               |
| Always allow customer | Also writes an allow rule on their email and phone, so their next payments go through |
| Block customer        | Also blocklists their email and phone. **This payment stays collected**               |
| Block and refund      | The same, plus a full refund of this payment                                          |

**Approve** and **Always allow customer** are available on every plan. If Shield refused someone you trust,
allowing them is how you release them: their next attempt goes through, and **Shield**, lists shows
who you allowed and lets you take it back. The two decisions that block are Shield Advanced, because
they write to the blocklist.

> [!NOTE]
> **Blocking alone leaves you holding the money**
>
> A flagged payment was collected. Blocking the customer only protects you from their next attempt.
> If you have decided a payment is fraud, **block and refund** is the decision that acts on the one
> in front of you, and it goes through the ordinary refund flow so you can follow it on the payment
> page.

## 5. Know what a block looks like

A blocked payment is not charged. The call returns `403`, the transaction stays `pending`, and your
integration gets `error_code: shield_blocked` with the support reference in `block_reference`.

```json title="Response · 403 Forbidden"
{
  "code": 403,
  "status": "Forbidden",
  "error_code": "shield_blocked",
  "message": "Payment blocked: transaction risk score too high. Please contact support and reference BLK-K3M9XQ2P.",
  "block_reference": "BLK-K3M9XQ2P"
}
```

Because the transaction is untouched, the payer can be offered another attempt on the same payment.
A retry is scored again, and is usually blocked again unless something about the payer changed.

## If you run your own checkout

If you built your own payment page and charge from your server with a secret key, call
`Wajub.signals()` in the payer's browser, send the result to your server, and pass it unchanged as
`data._client` on the charge. Your `ip` and `country`
[blocklist entries](https://docs.wajub.com/risk/shield/rules#the-blocklist), and your rules on IP country, need it.

```js title="In the payer's browser"
const signals = await Wajub.signals();

// Send it to your server with the order, then on to the charge as data._client.
await fetch('/checkout', { method: 'POST', body: JSON.stringify({ order, signals }) });
```

```js title="Charge with the payer's signals"
// On your server: the object Wajub.signals() returned, passed unchanged.
const body = {
channel: 'card',
data: {
  payment_method_id: 'pm_1PqR8xLkdIwHu7ix0aB3cD4e',
  _client: signals,
},
};
```

The value is short-lived, so call `Wajub.signals()` while the payer is on your payment page, and
send it with every charge. It never rejects, so it cannot hold up your checkout.

- [Shield](https://docs.wajub.com/risk/shield): Where the score sits in a payment, and what the plans differ on.
- [Shield Rules](https://docs.wajub.com/risk/shield/rules): Custom rules, the blocklist and the allowlist, and which one wins.
- [Risk Scoring](https://docs.wajub.com/risk/shield/risk-scoring): What the score means, and the levers that are yours.
- [Disputes](https://docs.wajub.com/payments/disputes): Responding to a dispute, and what a lost one can add to your blocklist.
