Guides Restore purchases

Restore purchases

Let buyers restore purchases in another browser or profile with an email code or a license key, and understand how devices are counted.

Buyers have no accounts or passwords. Access is tied to an install (one copy of your extension in one browser profile) and, once someone pays, to a customer identified by their checkout email. Restoring links a new install to that customer, so add a restore link wherever you show an upgrade button.

// popup.js
import { bill } from './bill'

const restoreLink = document.getElementById('restore')

restoreLink.addEventListener('click', (event) => {
  event.preventDefault()
  bill.openRestore()
})

function render(user) {
  restoreLink.hidden = user.paid
}

render(await bill.getUser())
bill.onChange(render) // fires in every context once the restore completes

The shared bill client is set up in the Quick start. In a framework, call bill.openRestore() from a button: see Frameworks. The Paywall UI has the restore link built in.

Why restore is needed

On first start, bill.startBackground() registers a new install and stores a random installId plus an install token in chrome.storage.local, mirrored to chrome.storage.sync. Another computer signed into the same browser profile with sync on picks up the synced identity and shares the same install, purchases included, and clearing only the extension’s local storage keeps the install. The buyer gets a brand-new install, with no purchases, when they:

  • remove and reinstall the extension (the browser deletes its synced data on uninstall too),
  • use another browser, browser profile or account,
  • have browser sync turned off and move to another computer or clear extension data, or
  • use a browser without storage.sync (such as a Firefox temporary add-on).

Two computers that both register before sync catches up can also end up as two installs.

Their purchase is still safe on the customer record. They only need to prove they own the email address.

The restore flow

bill.openRestore() opens a hosted restore page in a new tab at https://app.extensionbill.com/restore/<id>, branded with your app name, icon and color.

  1. Your extension calls bill.openRestore(). The SDK creates a restore session for the current install. The session is valid for 1 hour.

  2. The buyer enters the email they used at checkout. ExtensionBill emails them a one-time code. Codes expire after 10 minutes, and up to 5 codes can be sent per email address in 15 minutes.

  3. The buyer enters the code. They have 5 attempts per code. A wrong code shows otp_invalid; too many wrong codes show otp_too_many_attempts and they request a new one; an old code shows otp_expired.

  4. The install is linked to the customer. Every active entitlement of that customer (one-time purchases, active subscriptions, manual grants) now applies to this install, and user.customer is set to their email.

  5. The page reports the result. The verify call returns { "status": "completed", "hasPurchases": true } when the email has active purchases. When hasPurchases is false, the page tells the buyer no purchases were found for that address so they can try the email they paid with.

  6. Your extension updates. The SDK refreshes the user state when the restore tab finishes or closes. bill.onChange fires in every context, and bill.onPaid fires if the install just became paid.

In sandbox, restore codes are sent to the real email address entered on the restore page. Use an inbox you can read when you test.

License keys as an alternative

If a product has license keys enabled, buyers can activate the key they received at checkout with bill.activateLicense(key, label?) instead of using the email flow. This works well when:

  • the buyer can’t receive email on the device (shared or locked-down machines),
  • one person buys and someone else uses the extension (team purchases), or
  • you want a hard limit on how many devices can use one purchase.

Offer both in your UI: “Already purchased? Restore with your email” and “Have a license key?”.

Multiple devices and profiles

How many installs can share one purchase depends on how access was restored:

Restored withDevice limitWho can remove a device
Email codeNone. Any number of installs can link to the same customer email.n/a
License keyThe product’s seat limit (default 3, or unlimited).Buyer in the customer portal, you in Customers → Licenses, or the extension via bill.deactivateLicense().

Email-restored purchases are attached to the customer, so a subscription renewed or canceled on one device updates every linked install on its next refresh. A refund or revocation removes access from all of them. To cap devices, enable license keys on the product and ask buyers to activate a key (see seat limits).

Signing a device out

The SDK has no sign-out method. A buyer stops using a purchase on a device by:

  • License keys: clicking Remove device in the customer portal, or a “Deactivate” button in your extension that calls bill.deactivateLicense().
  • Email-linked installs: removing the extension from that browser. Uninstalling deletes the extension’s local and synced storage, including the install token, and reinstalling creates a new, unlinked install. Other computers on the same synced profile that already picked up the identity keep it locally and stay linked until the extension is removed there too.

The SDK HTTP API includes POST /v1/sdk/logout, which unlinks the customer from the calling install. It’s authenticated with the install token the SDK manages internally and isn’t wrapped by the public SDK, so don’t build product features on it.

From the dashboard: remove a license activation in Customers → Licenses, and withdraw access you granted manually to a single install on its page in Customers → Installs. An email-linked install can’t be unlinked from the dashboard; ask the buyer to remove the extension from that browser profile (and from other computers that share it through sync).

Support checklist

When a buyer says “I paid but it still shows Free”:

  1. Ask for the email they used at checkout and look it up in Customers. Confirm the order is paid (pending PayPal eCheck payments grant access only once they complete).
  2. Ask them to click Already purchased? Restore and enter that exact email.
  3. If they never receive the code, check the address for typos and their spam folder. They can request a new code after the rate limit window.
  4. Ask for the install ID your extension shows (await bill.getInstallId()) and open it in Customers → Installs to see its linked customer and current access.
  5. As a last resort, grant access to that install manually from the install detail page.

Customize

Confirm the restore

bill.onPaid fires once the restored install becomes paid, so you can thank the buyer without polling:

const restoreStatus = document.getElementById('restore-status')

restoreLink.addEventListener('click', () => {
  restoreStatus.textContent = 'Check the new tab: enter the email you used to buy.'
})

const stopListening = bill.onPaid((user) => {
  restoreStatus.textContent = `Welcome back! ${user.plan.name} is active on this browser.`
  stopListening()
})