Most Chrome extensions start free and add a paid tier later. The user clicks "Upgrade", pays, and expects the extension to unlock. That sounds simple. In a Manifest V3 extension it is not, because an extension has no server of its own, and anything it ships to the user is visible to the user.
The problem with checks inside the extension
An extension is a package the browser installs from the store. Its JavaScript, its constants and its API URLs are readable by anyone who installs it, and an unpacked copy can be edited in minutes. Two consequences follow.
- You cannot store a Stripe secret key in the extension. Anything in the package is public.
- A check such as
if (isPro) enablePro()proves nothing. A user who edits the file can make the condition true.
Client-side state is fine for interface decisions. It is not proof that someone paid. The proof has to come from a system the user cannot edit: Stripe, plus a record that a server keeps for you or that a service keeps for you.
Manifest V3 constraints that shape the design
- The background logic runs in a service worker, not in a persistent background page. The browser stops it when it is idle and starts it again on events. Keep state in
chrome.storage, not in global variables. - Remotely hosted code is not allowed. You cannot fetch a script from your server and run it. All executable code ships in the package. Data from your server, such as JSON, is fine.
- Extension pages use a restrictive default Content Security Policy that blocks inline scripts. Attach event handlers from script files instead of inline attributes.
- Declare your API host in
host_permissions. Otherwise your server must answer with CORS headers that allow the extension origin.
What a payment system has to do
Whatever you build, it has to cover five things:
- Take the payment, including the authentication steps that some cards require.
- Record the paid state against an identity.
- Keep that state in sync with renewals, failed renewals, cancellations and refunds.
- Let a paying user get access back on a new device or after a reinstall.
- Answer the extension quickly, and keep working when the network does not.
The identity question is the hard one. Extensions have no login by default. The usual choices are a random install ID stored in chrome.storage.local, which is lost on reinstall, or an account with an email address the user confirms. The install ID is simple and private but cannot follow a user. The account is portable but adds a sign-up step. Pick one before you write any payment code.
The DIY architecture in outline
A minimal self-built setup has four parts: the extension, a backend, Stripe Checkout and Stripe webhooks.
- Identity. The extension creates a random ID on first run and stores it in
chrome.storage.local. - Checkout. The extension calls your backend, for example
POST /checkout. The backend creates a Stripe Checkout Session inpaymentorsubscriptionmode, setsclient_reference_idto the extension ID, and puts the plan in the session metadata. It returns the session URL, and the extension opens it in a new tab. - Payment. Stripe Checkout collects the payment and redirects the user to your success page.
- Webhooks. Stripe sends events to your endpoint, for example
checkout.session.completed,customer.subscription.updated,customer.subscription.deleted,invoice.payment_failedandcharge.refunded. Your handler verifies theStripe-Signatureheader against the raw request body, then writes the entitlement to your database. - Check. The extension asks your
GET /licenseendpoint with its ID, caches the answer with a timestamp inchrome.storage.local, and refreshes it in the background.
The database is the source of truth, and the extension holds a cache. The success redirect is not proof of payment, because a user can open the success URL without paying. Only the webhook counts.
What to watch out for
- Verify every webhook. Reject requests with a bad signature. Many frameworks parse the JSON body before your handler runs, and that breaks verification. Read the raw body.
- Make handlers idempotent. Stripe retries deliveries when your endpoint fails or times out, so the same event can arrive twice. Store the IDs of the events you have processed.
- Define "paid" for each subscription state. Active is clear. Past due, canceled with access until the period ends, and refunded need explicit rules, written down before launch.
- Decide what a refund does. For a one-time purchase, a full refund usually revokes access. Put that in your policy and in your code.
- Plan for reinstalls. With an anonymous ID, a reinstall loses the purchase unless users can claim it, usually by confirming an email address.
- Decide how long the cache is trusted. If the extension fails closed when your API is down, paying users lose access during outages. If it fails open, a canceled user keeps access longer than intended. Pick a window, for example a few days, and document it.
- Test the whole path. Use Stripe test mode for the backend. Check the cancel flow, the failed-payment flow and the refund flow, not only the happy path.
- Operations are yours. Hosting, backups, log retention, alerts on failed webhooks and key rotation all belong to you.
- Tax, invoices and withdrawal rights are yours too. Stripe processes the payment. Tax treatment, invoices and consumer rights in each market remain your responsibility, and so does the privacy notice for the customer data you store.
The hosted route
A hosted service takes over the backend parts. With ExtCharge you connect your own Stripe account through Stripe Connect (Standard), register your extension in the dashboard, and add your plans. Payments are direct charges on your Stripe account, and ExtCharge never holds the money. Webhooks, subscription states and the license check run in the service. The extension code stays short:
// background.js
importScripts("ExtCharge.js");
const extcharge = ExtCharge("your-extension-id");
extcharge.startBackground();
// popup.js
const extcharge = ExtCharge("your-extension-id");
document.addEventListener("DOMContentLoaded", async () => {
const user = await extcharge.getUser();
if (user.paid) enablePro();
else document.querySelector("#upgrade").onclick = () => extcharge.openPaymentPage();
});
The manifest needs the storage permission and a content script on https://pay.extcharge.com/* that loads ExtCharge.js. The full manifest and the setup steps are in the integration guide.
Two details matter. The background script must call startBackground(), because that is where the paid and trial signals arrive. And the content script on the payment domain is what tells the extension that a payment succeeded, so it is required for onPaid.
Trade-offs
- Fee. ExtCharge charges 5% per transaction, on top of Stripe's own processing fees. Compare that with what your own backend costs to run and build, including your hours.
- Dependency. The entitlement check depends on a third-party service. Read the terms before you rely on it.
- Control. DIY lets you build any checkout flow you like. The hosted route gives you the plans and flows the service offers.
- Hosting. ExtCharge's servers are in Frankfurt, Germany, and operated by Solytics GmbH. Transactional emails go through Amazon SES, which is located in the USA. A data processing agreement is available.
- Testing. Payments run in live mode, with no ExtCharge test mode. The practical test is a cheap one-time plan that you buy yourself and then refund in your Stripe Dashboard. The refund revokes the paid state.
If you need to own every line of the payment path, build it. If you want the webhook, subscription and license parts done and maintained by someone else, the hosted route saves the most time. Either way the first decision is the same: the check that unlocks a feature must come from a server, not from the extension.