Back to blog

How to migrate your browser extension payments to ExtensionBill

Migrate browser extension payments to ExtensionBill: map checkout and license checks to SDK calls, update the manifest, and keep paying users unlocked.

ExtensionBill Team 8 min read

Most extensions that already make money got there with something hand-rolled: a Stripe or PayPal payment link, a small server that remembers who paid, a license check, maybe a webhook handler that flips a flag. When you migrate browser extension payments to ExtensionBill, all of that collapses into a few SDK calls and PayPal checkout, with no server of your own. The hard part isn’t the code. It’s moving the people who already paid you without charging them twice or locking them out.

This guide covers both: which SDK call replaces each piece of your current setup, what changes in the manifest and background script, and a staged rollout that keeps your existing paying users unlocked. If you’re starting from zero instead, follow how to add payments to a Chrome extension.

Before you start

Two facts shape the whole migration:

  • Payments and subscriptions stay where they were made. One-time purchases are already paid, so you only need to grant access again. Subscriptions billed by another system can’t be moved into ExtensionBill; existing subscribers keep access until the end of the period they paid for, then subscribe through ExtensionBill checkout.
  • Identities don’t carry over. The SDK registers its own install and never reads whatever your extension stored before, so after the update every user is a new ExtensionBill install. Paying users get their access back by email, as described below.

Set up your ExtensionBill app, PayPal sandbox and products first by following the quickstart. Note each product’s entitlement key (for example pro): that’s the string your code checks from now on.

Map your current setup to the SDK

Every call below is documented in the SDK reference.

What you have todayExtensionBillNotes
A payment link or page you open in a tabbill.openCheckout()Opens the hosted plan picker with all active prices.
A link to one specific planbill.openCheckout(priceId)Price IDs come from Sell → Products or getPlans().
A “manage subscription” linkbill.openPortal()Hosted customer portal: receipts, plan changes, cancellation, license devices.
A server endpoint that answers “has this user paid?”bill.getUser() + bill.hasAccess(user, 'pro')Cached for 5 minutes and works offline from a signed token.
A webhook handler that marks users as paidNothing to writeExtensionBill handles PayPal webhooks; bill.onPaid(cb) tells your extension.
A hard-coded price list in your UIbill.getPlans()Returns { app, plans, trial } with a ready-made formatted label per price.
Trial expiry math based on install datebill.startTrial() + bill.hasAccess(user)Trial length lives in your app settings; hasAccess handles expiry.
”Log in” or “I already paid” on a new devicebill.openRestore()Email one-time code; no accounts or passwords.
Your own license key validationbill.activateLicense(key, label?)Keys with device seats, revoked automatically on refund.
Support asking “which user are you?”bill.getInstallId()Look the ID up in Customers → Installs.

If your UI already refers to plans by a short name, prices carry an optional nickname you can use as a lookup key:

const { plans } = await bill.getPlans()
const yearly = plans.flatMap((plan) => plan.prices).find((price) => price.nickname === 'yearly')
await bill.openCheckout(yearly?.id) // no ID falls back to the plan picker

What the SDK tells you about a user

getUser() resolves with a UserState. These are the fields most homegrown setups track in some form:

You trackUserState fieldNotes
Paid or notpaidTrue while any entitlement is active. Use hasAccess() to include trials.
Which planplan{ name, entitlementKey, priceId, type, interval, intervalCount }. type is one_time, recurring, manual or license.
Every unlocked featureentitlementsEntitlement keys of every active product.
Subscription statussubscription?.statusapproval_pending, active, past_due, suspended, canceled or expired.
Cancellation datesubscription?.cancelAtAccess continues until this date.
Trialtrialavailable, active, startedAt, endsAt, daysLeft.
Emailcustomer?.emailSet once the install is linked to a buyer by checkout or restore.
Licenselicenselast4, status, seatLimit, seatsUsed, expiresAt. Never the full key.

There’s no purchase date or install date on UserState. If you need them, order paidAt and the install’s installedAt are available from the Server API.

If your old code checked status === 'active' by hand, switch to bill.hasAccess(user). A canceled subscription keeps access until cancelAt, past_due keeps access during your dunning grace period, and an active install trial unlocks everything. Trial math goes away too:

// Before: computing the trial yourself
const sevenDays = 1000 * 60 * 60 * 24 * 7
const trialActive = Date.now() - installedAt < sevenDays

// After
const unlocked = bill.hasAccess(user) // true while paid or user.trial.active

Dates in UserState are ISO 8601 strings, so wrap them in new Date() where you format or compare them.

Manifest changes

The SDK needs the storage permission. alarms is optional and lets it refresh paid status in the background. It needs no host_permissions and no content scripts, so remove anything you added only for your old billing setup:

  • host permissions for your licensing server or payment provider,
  • content scripts that ran on your payment or success page to detect a purchase,
  • connect-src entries in content_security_policy for the old billing API.
{
  "manifest_version": 3,
  "background": { "service_worker": "background.js", "type": "module" },
  "permissions": ["storage", "alarms"],
  "externally_connectable": { "matches": ["https://app.extensionbill.com/*"] }
}

externally_connectable is optional. It lets the hosted success page ping your extension so features unlock the moment payment completes; it grants no permissions and causes no install warning. Without it, the SDK still detects the purchase by watching the checkout tab. Dropping host permissions can also help your install rate; see how Chrome extension permissions affect installs. Firefox needs an explicit add-on ID and a scripts background entry; see Firefox and Edge.

Background setup

Create the client once in a shared module and import it in every context:

// bill.js
import { ExtensionBill } from '@extensionbill/sdk'

export const bill = ExtensionBill({ publishableKey: 'pk_test_…' })
// background.js
import { bill } from './bill.js'

bill.startBackground()

Call startBackground() once, synchronously, at the top level of the service worker. Never inside a callback, after an await or in an event listener. MV3 workers restart on demand, and only listeners registered during the first synchronous run receive the event that woke the worker. More on that in why your extension service worker keeps dying.

No bundler? Copy extensionbill.global.js into your extension and load it with importScripts('extensionbill.global.js', 'bill.js') in a classic service worker. Details are in Without a bundler.

How existing paying users keep access

ExtensionBill can’t read your old payment records, so you bring paying users over by email.

  1. Export your paying customers’ emails from your current payment provider or database, along with the end of the current paid period for subscribers.
  2. Grant access by email with the Server API, one call per user:
curl https://api.extensionbill.com/v1/entitlements \
  -X POST \
  -H "Authorization: Bearer sk_live_..." \
  -H "Content-Type: application/json" \
  -d '{
    "customerEmail": "buyer@example.com",
    "productId": "<your Pro product ID>"
  }'

Omit endsAt for lifetime purchases. For subscribers, set endsAt to the end of the period they already paid for. Run this from your own machine or server; sk_… keys never go in extension code. Full reference: Grant access. For a handful of users, the dashboard’s Grant access on a customer does the same thing. 3. Users restore with their email. In the new version, the user clicks your restore link, which calls bill.openRestore(), enters the email they paid with and confirms a one-time code. Every install that restores with that email gets the access, and bill.onPaid fires.

If a product has license keys enabled, you can instead issue a key per user from Licenses and have them paste it into your extension, which calls bill.activateLicense(key). Either way, nobody pays twice.

Stop renewals in your old billing system for the subscribers you moved, so nobody is billed by both. When their granted period ends, onChange fires as access drops and your paywall can invite them to subscribe through ExtensionBill checkout.

After a restore, the install identity is mirrored to chrome.storage.sync, so other computers signed into the same browser profile with sync on share that install and its access. A reinstall is a new install: Chrome deletes an extension’s synced data when it’s uninstalled, so the user restores again (or uses their license key). Keep your restore link visible to free users permanently.

Staged rollout checklist

  1. Build against sandbox. Replace your old calls using the mapping above with a pk_test_… key, load the extension unpacked and complete a sandbox purchase.
  2. Test the migration path in sandbox. Grant a sandbox entitlement to your own email with an sk_test_… key, then run the restore flow in a fresh profile and confirm hasAccess turns true.
  3. Add a restore prompt to your popup or paywall: “Already paid? Restore with the email you used.” The Paywall UI has a restore link built in.
  4. Go live. Connect live PayPal credentials, finish the going live checklist and put your pk_live_… key in the store build.
  5. Grant access in live to every paying email right before you publish, so restores work from the first minute.
  6. Publish the update, then email paying users the restore steps.
  7. Watch support. When someone says “I paid but it shows Free”, look the email up in Customers, ask them to restore with that exact address, and use bill.getInstallId() to find their install. The restore purchases guide has the full checklist.
  8. Clean up. Once restores settle, remove the old billing code, stop renewals in the old system for anyone you moved, and retire the server you no longer need.

Where to go next

The five-minute setup with your real keys is the ExtensionBill quickstart, and every method and type is in the SDK reference. If you’re rethinking your trial while you migrate, read how to add a free trial to your Chrome extension, and for pricing and model choices, see how to monetize a Chrome extension in 2026.