> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aifinpay.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Charge everyone who has not proven they may read

> Readers who passed a quick browser check and verified search engines read free. Everyone else, including scrapers that pretend to be browsers, gets your price.

By default AiFinPay charges AI agents that say who they are, and everyone else
reads free. That lets a scraper read free just by claiming to be a browser.
With this setting it is the other way round: only visitors who have proven they
may read free get the page, and everyone else gets your price.

## Who reads for free

* **A reader whose browser passed a quick check.** The check is Cloudflare
  Turnstile. It runs in the background. When it passes, the browser keeps a
  pass for 30 days. The pass is tied to the name the browser sends (its
  User-Agent).
* **A search engine whose network has been verified.** Google, Bing, Apple,
  Yandex and Baidu crawlers read free when their address really belongs to that
  company. A crawler that only calls itself Googlebot pays.
* **Nobody else.** An AI agent that sends an AiFinPay receipt or agent ID always
  pays, whatever else it sends. A verified AI crawler pays too.

On WordPress, a user who is signed in to your site also reads free.

## What a reader sees

A reader opens a paid page and sees it at once: the title, the layout and
everything around the article. The paid part loads in a moment later, when the
check has passed, without reloading the page. After that, paid pages open whole
for 30 days.

The check runs unseen. If Cloudflare does not trust a browser, it may ask for
one click. We kept that click so that a real person is never locked
out.

While the paid part is still loading, the page tells search engines not to
index it and tells caches not to store it.

## What everyone else gets

| Visitor | What it gets |
| - | - |
| A script (curl, a scraper), whatever it calls itself | The price (`HTTP 402`), without your text |
| An AI crawler such as GPTBot | The price, without your text |
| An AI agent with a valid AiFinPay receipt | The page, counted against what it paid |
| A verified search engine | The page |
| A crawler that only claims to be a search engine | The price, without your text |

A visitor that does not ask for a web page gets the price as data an agent can
read. A browser that has not passed the check gets the page with the price
inside it, so an agent that drives a browser also learns how to pay.

## The three settings

The setting is called **Who reads for free**. It applies to protected paths in
Enforce.

| Setting | Who reads free | Pick it when |
| - | - | - |
| **AI agents only** | Every visitor that does not say it is an AI agent | You want to start gently. This is the default, and sites that were set up before this setting keep it. |
| **Strict** | Readers with a pass, verified search engines | Scrapers that pretend to be browsers are reading your paid pages. |
| **Everyone pays** | Nobody | The section is meant for machines only, such as an API or a data feed. |

In configuration and in code the three are stored as `named`, `proven` and
`everyone`.

> [!WARNING]
>
> **Strict** needs a Turnstile site key and secret key. Until both are saved, it
> acts as **Everyone pays**: everyone pays on protected paths, readers too. It
> never falls back to free. The settings page says what is missing.

## Before you start: a Turnstile widget

The check is Cloudflare Turnstile. A free Cloudflare account is enough, and
your site does not have to run on Cloudflare for WordPress and Drupal.

**1. Create the widget**

In your Cloudflare account open **Turnstile**, add a widget for your site's
domain, and choose **Managed** mode.

**2. Copy the two keys**

Cloudflare shows a site key and a secret key. You paste both into your
plugin or module. The plugin or module makes its own reader key; you never
see or copy it.

When the check passes, your site sends the check result, your secret key and
the visitor's IP address to Cloudflare to confirm it. The pass the browser
keeps holds an expiry time and a signature, nothing that identifies the
visitor.

## Set it up

### WordPress

You need the [WordPress plugin](https://docs.aifinpay.io/charge/wordpress.md) 0.4.0 or later, connected to
AiFinPay and in Enforce.

**1. Choose the setting**

In **Settings → AiFinPay**, under **Who reads for free**, choose
**Strict**. In plugin 0.4.0 it is the second choice in the list.

**2. Paste the keys**

Paste the **Turnstile site key** and **Turnstile secret key** and save. The
**Status** table shows which setting is in force.

The plugin holds the paid text back inside WordPress: from the page, the
excerpt, feeds and the REST API. If your theme or page builder prints the post
text in a way the plugin cannot hold back, the visitor gets a short page with
the price instead, and the whole page after the check.

### Drupal

You need the [Drupal module](https://docs.aifinpay.io/charge/drupal.md) in **Mode: Enforce** with
**Self-hosted gate**.

**1. Choose the setting**

In **Configuration → Web services → AiFinPay**, under
**Who reads for free**, choose **Strict**. In module 1.1.0 it is the second
choice in the list.

**2. Paste the keys**

Fill in **Turnstile site key** and **Turnstile secret key** and save. The
secret key stays on your server and is never in exported configuration.

**3. Check the paid fields**

**Paid fields** lists the fields of a page that are held back until the
check passes. The default is `body`. Add any other field that carries the
paid text.

A page with no paid field, or one that repeats its text somewhere else, gets a
short page with the price instead. Drupal's page caches never store a page
with the paid part held back.

### Cloudflare

If your site already runs on Cloudflare, a Worker can do the same at
Cloudflare, in front of your site. It uses Cloudflare's own list of verified
bots, so search engines, link previews and uptime monitors read free, and AI
crawlers do not. It works on its own or in front of the WordPress plugin or
Drupal module.

You need Node 22 or later and a Cloudflare API token for your zone, set as
`CLOUDFLARE_API_TOKEN`. The installer creates the Turnstile widget itself.

**1. See what it would change**

```bash theme={null}
npx @aifinpay/gate-cloudflare install news.example.com --merchant mrch_... --payment origin --selector .entry-content --mode enforce --dry-run
```

With `--dry-run` it reads your zone, prints every change and makes none.

**2. Install**

Run the same command without `--dry-run`. It uploads the Worker, adds a
route for that one host and two rules scoped to it, and leaves every other
rule as it is.

| Option | What to give it |
| - | - |
| `--merchant` | Your site's ID from the dashboard. |
| `--payment origin` | Your site already runs the WordPress plugin, the Drupal module or a gate package. The Worker only decides who has to pay. |
| `--payment edge` | Nothing runs on your site. The Worker also prices, checks receipts and counts. Name the paid addresses with `--paid-prefix /articles/`. |
| `--selector` | The part of the page that is paid, as a CSS selector: `.entry-content` on most WordPress themes, `.node__content` on Drupal. Without it an unproven browser gets a short page with the price. |
| `--mode` | `shadow` changes no page; `enforce` charges. |

To take it away again, run
`npx @aifinpay/gate-cloudflare remove news.example.com`. It deletes only what
the installer created. The
[package page](https://www.npmjs.com/package/@aifinpay/gate-cloudflare) lists
every option.

The token must be able to edit Workers Scripts, Workers Routes, Transform Rules
and Turnstile. We installed with an account-wide key; a token limited to these
four has not been tested yet.

### Your own code: Node and Python

The gate packages have the same rule as a building block: `unprovenPays` in
`@aifinpay/gate` 0.12.0 and `unproven_pays` in `aifinpay-gate` 0.9.0. They
issue and check the reader's pass and verify search engines. They do not run
the browser check: you add Turnstile to your pages yourself and issue the pass
when it succeeds.

> [tab] Node
>
> ```ts theme={null}
> import { aifpGate, createReaderProof, unprovenPays } from "@aifinpay/gate";
>
> const readerProof = createReaderProof({ key: process.env.AIFP_READER_KEY! }); // 32+ bytes
> app.set("trust proxy", "loopback"); // so req.ip is the client, not your proxy
> app.use("/articles", aifpGate({ merchantId, registry, shouldCharge: unprovenPays({ readerProof }) }));
>
> // After your own browser check passes:
> res.setHeader("Set-Cookie", readerProof.setCookie(readerProof.issue(req.get("user-agent"))));
> ```

> [tab] Python
>
> ```python theme={null}
> from aifinpay_gate import Gate, ReaderProof, unproven_pays
>
> reader_proof = ReaderProof(os.environ["AIFP_READER_KEY"])  # 32+ bytes
> gate = Gate(merchant_id, resource="/articles", should_charge=unproven_pays(reader_proof))
>
> # After your own browser check passes:
> response.headers["Set-Cookie"] = reader_proof.set_cookie(reader_proof.issue(request.headers.get("user-agent")))
> ```

The package READMEs for
[Node](https://github.com/AiFinPay/sdk/tree/main/gate#unproven-pays) and
[Python](https://github.com/AiFinPay/sdk/tree/main/python-gate#unproven-pays)
say which request field carries the visitor's address on each server.

## Behind a proxy or CDN

Search engines are verified by the visitor's IP address. If your site sits
behind a proxy, load balancer or CDN, your site must be told the real visitor
address. Otherwise every visitor seems to come from the proxy, no search engine
is verified, and they all pay.

* **WordPress**: configure your web server to pass the real address, or use
  the `aifinpay_client_ip` filter.
* **Drupal**: set `reverse_proxy` and `reverse_proxy_addresses` in
  `settings.php`.
* **Node and Python**: see the package READMEs linked above.

## What it does not stop

This setting makes a scraper prove itself before it reads free. It does not
stop every bot.

* **Automation in a real browser.** A script that drives a real, visible
  browser may pass the check and read free. We have not measured this.
* **A copied pass.** A reader's pass copied into a script that sends the same
  browser name reads free until the pass expires.
* **Pages cached elsewhere.** A CDN that keeps copies of your pages and does
  not run the AiFinPay Worker serves those copies without the check.
* **Google's AI answers.** Google's crawler collects pages for both Search and
  Google's AI answers. A verified Googlebot reads free, and this cannot be told
  apart per request.

The plugins also keep their other limits. On WordPress, for example, files in
`wp-content/uploads` cannot be protected, and a home page or archive that shows
the full text of a protected post shows it there too.

## What we measured

We ran the Cloudflare version on a test site on 2026-11-17, on Cloudflare's
free plan:

* curl with any browser name, GPTBot and a fake Googlebot got the price.
* A client that sent the "verified bot" mark itself still got the price.
* A forged pass got the price.
* A browser-like client got the page in about 0.4 seconds, with the real title
  and headline and without the paid text.
* Headless Chrome driven by Puppeteer, plain or disguised, did not read the
  paid text.

We did not measure a real Googlebot or a real verified AI crawler, automation
in a visible browser, or a pass copied from a real browser into a script.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.