---
name: fastmesh-creem-checkout
description: Self-serve Creem.io prepaid API credit checkout directory, 10-second order_id API key redemption, real-time micro-USD balance lookup, native Streamable MCP gateway, and idempotent HTML storefront checkout bar upgrader at https://pay.fastmesh.dev. Enforces strict human-in-the-loop checkout (never auto-fills payment cards or bypasses CAPTCHAs), SHA-256-only key storage, zero plaintext email PII, zero data resale, and $0 charge on miss or HTTP 422.
---

# FastMesh Pay & Self-Serve Creem Checkout Agent Skill

**FastMesh Pay** (`https://pay.fastmesh.dev`) is the unified self-serve Creem.io Merchant-of-Record checkout portal, 10-second API key minting vault, real-time micro-USD balance dashboard, and storefront upgrade kit serving all 33 verified FastMesh engines (99 live `prod_*` prepaid credit packs).

## Hard Security, Privacy & Billing Invariants

1. **Human-in-the-Loop Payment Boundary (CRITICAL)**:
   - Agents may discover products, compare tiers, and present verified `https://www.creem.io/product/prod_*` checkout links to the human operator.
   - **STRICTLY FORBIDDEN**: NEVER auto-fill credit cards or bank details, NEVER collect or log payment credentials, NEVER submit real money transactions autonomously without the human executing checkout, and NEVER solve, click through, or bypass CAPTCHAs or anti-bot challenges.
   - Always instruct the human operator to complete Creem checkout in their own browser and return the `order_id` (or `checkout_id`) and one-time `claim_token`.
2. **SHA-256 Hashed API Keys Only (One-Time Plaintext Display)**:
   - `POST /api/redeem` displays the newly minted `fm_live_...` API key **exactly once** (`shown_once: true`).
   - The server persists only `key_sha256` and a non-secret 12-character `key_prefix`. Never commit, echo, or log raw API keys; store them only in operator-controlled secrets or environment variables (`export FASTMESH_API_KEY="fm_live_example_redacted"`).
3. **Zero Plaintext Email PII & Zero Data Resale**:
   - Customer emails arriving in Creem webhooks are hashed immediately to `customer_ref_sha256_12` before persistence.
   - Prompts, conversations, queries, and execution traces are never sold, licensed, or used to train third-party models.
4. **Strict `$0` Charge on Miss or HTTP `422`**:
   - Invalid inputs (`HTTP 422`), empty catalog matches, or miss invocations (`hit=false`) strictly incur `$0` (`0` micro-USD).
5. **Anti-Arbitrage Refund Clawback**:
   - Settled `refund.created` webhooks atomically claw back remaining micro-USD and credits, mark the order `refunded` (blocking future redemption with `HTTP 409`), and revoke associated API keys when balance reaches zero or a full refund occurs.

## Prepaid Credit Tiers (One-Time, Non-Expiring, Non-Contingent)

| Tier | One-Time Price | Credits Granted | Micro-USD Ledger Value | Effective Price / Credit |
| :--- | :---: | :---: | :---: | :---: |
| **Starter** | `$19.00` | `2,000` credits | `19,000,000` micros | `$0.009500` |
| **Pro (Recommended)** | `$79.00` | `10,000` credits | `79,000,000` micros | `$0.007900` |
| **Scale** | `$249.00` | `40,000` credits | `249,000,000` micros | `$0.006225` |

## Step-by-Step Autonomous Agent Workflow

### Step 1: Discover Live Creem Products (`GET /api/catalog`)

Query verified live `prod_*` products by `subdomain`, `tier`, `wave_group`, or keyword `q`:

```bash
curl -sS "https://pay.fastmesh.dev/api/catalog?subdomain=verify&tier=pro"
```

Every returned product includes `product_id`, verified `checkout_url` (`https://www.creem.io/product/prod_*`), `sku_id`, `price_cents`, `credits_granted`, and `micros_granted`.

### Step 2: Hand Off Verified Creem Checkout Link to Human Operator

Present the exact product name, fixed one-time price, credit allocation, and `https://www.creem.io/product/prod_*` URL to the human operator:

> Example handoff message:
> "Please complete the one-time Creem checkout for **Verify-Anything — Pro Prepaid Pack ($79, 10,000 credits)** at `https://www.creem.io/product/prod_2Kzq0zSZqiESxCeWxI0C0P`. Once checkout finishes, share your `order_id` and one-time `claim_token` so I can mint or verify your API key."

Do **not** attempt to automate the browser payment page, enter payment instruments, or bypass any human verification prompt.

### Step 3: 10-Second Self-Serve Key Redemption (`POST /api/redeem`)

Once the human provides `order_id` (or `checkout_id`) and `claim_token`, redeem once:

```bash
curl -sS -X POST "https://pay.fastmesh.dev/api/redeem" \
  -H "Content-Type: application/json" \
  -d '{
    "order_id": "ord_example_123456",
    "claim_token": "tok_one_time_claim_example"
  }'
```

Expected status codes:
- `200 OK`: Returns `api_key` (`fm_live_...`, `shown_once: true`), `key_prefix`, `wallet_id`, `balance_micros`, and `balance_credits`. Prompt the operator to save the key immediately into `FASTMESH_API_KEY`.
- `401 Unauthorized`: Invalid `claim_token` (constant-time SHA-256 comparison failed).
- `404 Not Found`: Unknown `order_id` / `checkout_id`.
- `409 Conflict`: Order already redeemed or already refunded.

### Step 4: Check Micro-USD Balance & Itemized Receipts (`GET /api/balance`)

Verify active balance and double-entry receipts using `Authorization: Bearer` (or `X-API-Key`):

```bash
curl -sS "https://pay.fastmesh.dev/api/balance" \
  -H "Authorization: Bearer ${FASTMESH_API_KEY}"
```

Returns:
- `balance_micros` (integer micro-USD, `$1 = 1,000,000` micros)
- `balance_usd`
- `balance_credits`
- `total_credited_micros`, `total_debited_micros`
- `receipts[]` (itemized double-entry ledger entries including `$0` miss receipts)
- `orders[]` (associated order statuses without plaintext emails or raw keys)

### Step 5: Call Native Streamable MCP (`POST /mcp`)

Discover all flat MCP tools (`search_creem_catalog`, `redeem_order_key`, `check_key_balance`, `upgrade_storefront_html`):

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/list",
  "params": {}
}
```

Invoke `search_creem_catalog`:

```json
{
  "jsonrpc": "2.0",
  "id": 2,
  "method": "tools/call",
  "params": {
    "name": "search_creem_catalog",
    "arguments": {
      "subdomain": "verify",
      "tier": "pro"
    }
  }
}
```

Invoke `check_key_balance`:

```json
{
  "jsonrpc": "2.0",
  "id": 3,
  "method": "tools/call",
  "params": {
    "name": "check_key_balance",
    "arguments": {
      "api_key": "fm_live_example_redacted"
    }
  }
}
```

### Step 6: Upgrade Microsites via `storefront_upgrader.py`

Replace `#pricing` placeholders and inject the idempotent dark checkout bar (`<!-- FASTMESH_CHECKOUT_BAR_START -->` ... `<!-- FASTMESH_CHECKOUT_BAR_END -->`) safely:

Via REST preview endpoint:

```bash
curl -sS -X POST "https://pay.fastmesh.dev/api/upgrade-preview" \
  -H "Content-Type: application/json" \
  -d '{
    "subdomain": "verify",
    "html": "<!doctype html><html><body><a href=\"#pricing\">Buy Credits</a></body></html>"
  }'
```

Via local CLI (`storefront_upgrader.py`):

```bash
python3 -m src.storefront_upgrader \
  --subdomain verify \
  --input ./web/index.html \
  --output ./web/index.html
```

Running `upgrade_html()` once or `N` times produces byte-identical output, replacing `#pricing` links and `data-creem-tier="starter|pro|scale"` targets with verified `https://www.creem.io/product/prod_*` URLs while preserving surrounding markup.

### Step 7: Invoke via `treg hub` (0% Seller Commission)

```bash
treg call fastmesh-creem-checkout \
  --data '{"action":"recommend_pack","subdomain":"verify","monthly_calls":8500}'
```

## Offline Creem Webhook HMAC-SHA256 Verification (Python 3 Stdlib)

```python
import hashlib
import hmac

def verify_creem_webhook(raw_body: bytes, signature_header: str, secret: str) -> bool:
    """Verify Creem creem-signature header in constant time."""
    if not raw_body or not signature_header or not secret:
        return False
    provided = signature_header.strip()
    if provided.lower().startswith("sha256="):
        provided = provided.split("=", 1)[1].strip()
    expected = hmac.new(secret.encode("utf-8"), raw_body, hashlib.sha256).hexdigest()
    return hmac.compare_digest(expected.lower(), provided.lower())
```

## Discovery & Operator Support

- Portal Home: `https://pay.fastmesh.dev/`
- Machine Index: `https://pay.fastmesh.dev/llms.txt`
- OpenAPI 3.1.0 Spec: `https://pay.fastmesh.dev/openapi.json`
- Native MCP Endpoint: `https://pay.fastmesh.dev/mcp`
- Technical Guides (24 Pages): `https://pay.fastmesh.dev/guides`
- Support Email: `ops@fastmesh.dev`
