Creem HMAC-SHA256 Webhook Credit Top-Up API Gateway (Replay-Safe)
Creem acts as global Merchant of Record at 3.9% + $0.40 per transaction with $0/mo base fee, handling VAT/GST/sales tax and paying out on the 1st and 15th. Every server compiled by Monetize-Anything ships a hardened POST /webhooks/creem handler (alias /v1/webhooks/creem) using constant-time HMAC-SHA256 signature verification, SQLite WAL event_id replay idempotency, and automatic API key provisioning. Verified in our live adversarial Gauntlet (16/16 real non-mocked heterogeneous cases passing in 13546.33 ms total, median 305.8 ms, plus 34/34 unit tests under python3 -W default with 0 warnings).
HTTP 422, and empty or fake-200 errors bill strictly $0.00.
Deterministic Architecture & Billing Invariants
Raw request bytes are verified against CREEM_WEBHOOK_SECRET via core_kit.payment_kit.verify_creem_signature. Missing or forged creem-signature headers immediately return HTTP 401; valid events map product_id to micro-USD credits inside SQLite WAL BEGIN IMMEDIATE and ignore duplicate event_id retries safely.
1-Source → 3-Channel Publishing: Every compiled target emits (1) a self-hosted Creem prepaid storefront + SQLite WAL gateway (3.9% + $0.40 MoR, $0/mo base), (2) a remote Streamable JSON-RPC 2.0 /mcp endpoint + Causal Bazaar public card (b01_monetize_anything_compiler_v1), and (3) a 4-file treg_hub/ merchant pack at 0% commission (treg call monetize-anything).
Data-Backed Comparison & Live Benchmarks
| Webhook / Checkout Property | DIY Unhardened Handler | Monetize-Anything Creem Gateway | Verified Status |
|---|---|---|---|
| Forged Signature Attack | Attackers mint unlimited free credits | Constant-time HMAC-SHA256 -> HTTP 401 reject | Verified 401 in Gauntlet |
| Duplicate Retry Replay | Credits applied 2x-5x on webhook retries | UNIQUE event_id in SQLite WAL -> exact 1x credit | Verified idempotent in Gauntlet |
| Global Tax & MoR Overhead | DIY VAT/GST registration across 40+ countries | Creem MoR 3.9%+$0.40 ($0/mo base, payouts 1st & 15th) | 91.5% creator net take-home |
| Prepaid Credit Packs | Complex recurring seat proration | Starter $19 (2,500 cr) / Pro $79 (15,000 cr) / Agency $249 (65,000 cr) | Zero seat tax, zero sales calls |
Copy-Paste Integration Example
curl -i -X POST "https://monetize.fastmesh.dev/webhooks/creem" \
-H "Content-Type: application/json" \
-H "creem-signature: $HMAC_SHA256_HEX" \
-d '{"event_id":"evt_creem_live_001","eventType":"checkout.completed","object":{"product_id":"prod_pending_b01_monetize_starter_19","customer_email":"buyer@example.com"}}'
Deterministic Output
{
"ok": true,
"idempotent_replay": false,
"credited_micros": 19000000,
"api_key_provisioned": true
}
Implementation Steps
- Bind Creem SKUs in gateway_route.json: Map prod_pending_b01_monetize_starter_19 ($19), Pro ($79), and Agency ($249) product IDs to credit grants.
- Inject CREEM_WEBHOOK_SECRET via environment: Never hardcode secrets in code; read strictly from env or 0600 credential files.
- Verify 401 signature block & exact-once replay: Confirm forged digests fail with HTTP 401 and duplicate event_id calls never double-credit.
Frequently Asked Questions
What are Creem's verified Merchant of Record fees?
3.9% + $0.40 per checkout with $0/mo fixed base fee, global VAT/GST/sales tax handled automatically, and rolling payouts on the 1st and 15th.
Are both /webhooks/creem and /v1/webhooks/creem supported?
Yes. Both routes map to the identical HMAC-verified, replay-safe handler.
What happens if Creem retries a checkout.completed webhook?
The UNIQUE event_id table inside SQLite WAL detects the replay and returns HTTP 200 idempotent_replay: true with zero duplicate credits added.
support@fastmesh.dev.