Dev.to Security 🔐 Cybersecurity 👁 0 📖 6 min read

I almost unlocked Pro from a URL parameter. What I changed before launch.

I build a small SaaS called ClauseRadar (https://clauseradar.online/?utm_source=devto&utm_medium=article&utm_campaign=paywall-lessons). It reads contracts (freelance agreements, brand deals, job offers) and flags clauses

I build a small SaaS called ClauseRadar (https://clauseradar.online/?utm_source=devto&utm_medium=article&utm_campaign=paywall-lessons). It reads contracts (freelance agreements, brand deals, job offers) and flags clauses like "payment within 90 days" or "contractor's liability is unlimited". I'm in India, I work alone, and I deploy from my phone using Termux. I build with an AI coding assistant doing much of the typing, while I decide what ships and test it.

This post is about three mistakes I made or nearly made. The first one is the most useful if you are about to add a paywall.

The paywall idea that looked fine for ten minutes

I was moving from manual UPI payments to Whop checkout. My plan:

  1. User clicks Upgrade and goes to Whop.
  2. Whop redirects them back to /dashboard?unlock=some_secret_string after payment.
  3. My frontend sees the parameter, marks the user as Pro, and removes the parameter from the address bar with history.replaceState.

It feels safe because the secret only appears after a successful payment. It is not safe, for four reasons:

• Anyone who pays once can read the URL and share it. Every person who gets the link gets Pro for free.
• The check lives in the browser, so the secret is inside your JavaScript bundle. Open DevTools, search the bundle, done.
• replaceState hides the URL from the address bar, not from history, analytics, or extensions. It also runs after the page has already loaded with the secret in it.
• Nothing server-side knows the user paid. Pro would exist only in localStorage. Clear it and the user is back on Free, or edit it and the user is Pro.

Whop's own docs say much the same: the redirect only brings the buyer back, and access should come from the payment webhook.

What I built instead

The rule I settled on: the browser can ask "did my payment arrive?" but it can never say "I paid". Pro is granted in one place only, a webhook handler that verifies a signature first.

Whop --(signed POST payment.succeeded)--> /api/whop-webhook --> database (Pro days added)
Browser --(logged in, "check my status")--> /api/whop-claim --> reads the database, answers yes/no

The redirect URL still exists, but it is only a hint. When the user lands on /dashboard?paid=1, the app strips the parameter and starts polling /api/whop-claim for about a minute. The toast "Welcome to Pro" appears only when the server confirms a payment record for that account.

Verifying the webhook

Whop uses the Standard Webhooks scheme: an HMAC-SHA256 over id.timestamp.rawBody. The detail that catches people is the raw body. If your framework parses JSON first and you re-stringify it, the bytes change and the signature fails.

import crypto from "node:crypto";

function verifySignature(raw, headers, secret) {
const id = headers["webhook-id"];
const ts = headers["webhook-timestamp"];
const sigHeader = headers["webhook-signature"];
if (!id || !/^\d+$/.test(String(ts || "")) || !sigHeader) return false;

const expected = crypto
.createHmac("sha256", secret)
.update(id + "." + ts + ".")
.update(raw)
.digest();

return String(sigHeader).split(" ").some((entry) => {
const [version, sig] = entry.split(",");
if (version !== "v1" || !sig) return false;
const got = Buffer.from(sig, "base64");
return got.length === expected.length && crypto.timingSafeEqual(got, expected);
});
}

I read the body from the request stream before anything touches req.body. Check Whop's current docs for how they want the signing secret used; I pass the ws_... value exactly as the dashboard shows it.

Making it idempotent

Webhooks get retried. A payment must never add 30 days twice. The payment ID is the primary key, so the second insert does nothing:

insert into whop_payments(id, email, plan_id, days)
values (p_pay, lower(trim(p_email)), p_plan, p_days)
on conflict (id) do nothing;

if not found then return 'duplicate'; end if;

Two more decisions that matter:

• The plan to days mapping lives on the server. The webhook looks up the plan ID and decides 30 or 365 days. The browser never sends a duration.
• Payments are matched to accounts by confirmed email. If someone pays with a different email, the payment waits as "unclaimed" and nobody gets Pro by guessing.

Mistake two: CSS blur is not a paywall

Free users see the first clauses of a report and a blurred preview of the rest. The tempting way to build that is to ship the full text to the browser and blur it. Anyone can delete one CSS rule.

Now the audit endpoint seals the locked parts with AES-256-GCM before they leave the server, and a separate unlock endpoint decrypts them only after it checks the user's plan. The free client never has the plaintext to reveal. If your paywall is a CSS class, it is a suggestion.

Mistake three: my own installer deleted the app

This one is less about security and more about humility. I deploy by running one self-contained Node script in Termux. It writes files, runs node --check, does a prerender dry run, runs npm run build, pushes to git, and rolls everything back if a step fails.

To avoid a flash of unstyled content, I added a skeleton

above the app root in index.html. After that, users reported a page stuck on grey blocks. The console said:

TypeError: Cannot read properties of null (reading 'appendChild')

The cause was one line in my installer, which found the app root like this:

const rootM = existing.match(/<div\s+id="([^"]+)"/i);

The first

was now boot. Each re-run rebuilt index.html from the previous output and replaced with . The framework then had nothing to mount into. My tests missed it because each test started from a fresh project.

Two fixes:

  1. Read the mount target from src/main.js (getElementById("app")) and never treat boot as a root.
  2. Make the loading state fail open. A tiny inline script listens for script errors and, after six seconds, removes the skeleton and shows the static server-rendered page with an error line. A permanent skeleton is worse than an ugly page.

If you hide server-rendered content behind a skeleton, think about what the user sees when your JavaScript fails.

Smaller notes

• Prerendering: I generate static HTML for every route at build time (114 pages), so crawlers and slow phones get real content. The build fails if a page is missing its title, canonical link or schema block.
• Programmatic SEO is risky: I generated about a hundred guide pages (employment bonds, MSMED payment notices, brand-deal clauses). Google can treat mass-produced pages as low value, so if you do this, publish in batches and check indexing before adding more.
• Billing text must match reality: After moving to Whop, one account page still said "renewal is manual". Grep your UI for old payment language.

Where it stands

ClauseRadar launched in October. As of mid-November it has early organic signups and is iterating toward its first paying users. The stack is Svelte with Vite, Vercel serverless functions, Supabase (auth and Postgres with row-level security), and an LLM for the audit.

Try it, and tell me what's wrong with it

Scanning is free: https://clauseradar.online/?utm_source=devto&utm_medium=article&utm_campaign=paywall-lessons. If you sign client contracts, upload one with the names removed and tell me which clauses it missed. That feedback helps more than a star.

ClauseRadar is a product of HanuraGlobal. I'm Pintu Ray, the founder. Updates are on X (https://x.com/clauseradar) and Instagram (https://www.instagram.com/clauseradar).

Disclaimer: ClauseRadar is an automated review tool, not a law firm, and nothing here is legal advice. This post was drafted with AI assistance and edited by me.

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.