Checkout & one-time payments
How a hosted checkout session runs from openCheckout to a captured PayPal payment, and what ExtensionBill does after the buyer pays.
Every purchase runs through a checkout session: a hosted page at https://app.extensionbill.com/pay/<sessionId> that collects the buyer’s details and renders PayPal’s buttons. Read this page to customize checkout or to understand what happens between openCheckout() and access. Subscriptions use the same page; what happens after approval is in Subscription lifecycle.
bill.openCheckout()
→ POST /v1/sdk/checkout-sessions returns { id: "cs_…", url }
→ new tab: /pay/cs_… plan picker, details, PayPal buttons
→ buyer approves in PayPal
→ ExtensionBill captures and verifies order "paid"
→ entitlement, license key, emails, webhooks
→ the SDK sees the tab finish and refreshes; onPaid fires
Your extension never touches card data or PayPal credentials. The money goes straight into your PayPal Business account.
Opening checkout
Call bill.openCheckout() from any context: popup, options page, content script or service worker.
// popup.js
import { bill } from './bill.js'
// One price (copy the price ID from Sell → Products), with optional prefills
document.querySelector('#buy-lifetime').addEventListener('click', () => {
bill.openCheckout('66f2a1c4e9b0a3d1c2b4e5f6', { email: 'buyer@example.com', discountCode: 'LAUNCH20' })
})
// No price ID: the hosted page shows a plan picker with every active price
document.querySelector('#see-plans').addEventListener('click', () => {
bill.openCheckout()
})
The SDK sends { priceId?, email?, discountCode? } to POST /v1/sdk/checkout-sessions and opens the returned url in a new tab. Session IDs start with cs_ and are valid for 24 hours; after that the page shows an expired state and the API answers 410 checkout_expired. Call openCheckout() again for a fresh one.
Errors when opening checkout
openCheckout() rejects with an ExtensionBillError. Branch on code:
// popup.js
import { bill } from './bill.js'
const status = document.querySelector('#status')
async function buy(priceId, discountCode) {
try {
await bill.openCheckout(priceId, { discountCode })
} catch (err) {
if (err.code === 'price_unavailable') {
status.textContent = 'This plan is no longer on sale. Pick another one.'
} else if (err.code === 'discount_invalid') {
await bill.openCheckout(priceId) // retry without the code
} else if (err.code === 'paypal_not_connected') {
console.error('Connect PayPal for this environment in Settings → PayPal')
} else {
throw err
}
}
}
All codes: Error codes.
What the buyer sees
-
Plan picker, only when you called
openCheckout()without a price ID. Every active product and price is listed with its features, interval, trial and setup fee. Highlighted products get visual emphasis. -
Details.
- Email (required; prefilled when you passed
email). The receipt, license key and portal access all hang off this address. - Name, when Collect name is on in Settings → Checkout.
- Custom fields you defined in Settings → Checkout (text or select, required or optional), stored on the order as
customFields. - Discount code, when Allow discount codes is on. Totals update immediately; an unknown or expired code shows an inline error.
- A tax line, when you set a tax rate (Taxes).
- A consent checkbox for a reminder email, only when that feature is on.
- Email (required; prefilled when you passed
-
Pay with PayPal. PayPal’s Smart Buttons: PayPal (wallet login in a PayPal popup), Pay Later (when PayPal finds the buyer and amount eligible) and Debit or Credit Card (guest checkout, no PayPal account). PayPal’s eligibility rules for country, currency and device decide which appear; ExtensionBill does not filter them.
-
Result. A success, processing or failure state, inline, without a redirect.
The PayPal order uses your app name as brand_name, so buyers recognize it in the PayPal popup and on their statement. Shipping is off (NO_SHIPPING).
One-time purchase workflow
After the buyer approves the payment in PayPal:
-
Server capture. ExtensionBill captures the PayPal order with your credentials and verifies it against the session: amount and currency must match the server-computed total, and
custom_idmust equal the session ID. A mismatch is never marked as paid (409 paypal_amount_mismatch). -
Order paid. The order is recorded as
paidwith a number such asEB-LX2K9Q4. It is also the receipt number and the PayPalinvoice_id, so you can search for it in PayPal. -
Entitlement granted for the product’s
entitlementKey. One-time prices grant lifetime access, unless the product has a license duration (license.durationDays). -
License key issued, when enabled on the product. It is shown once on the success page and emailed (License keys).
-
Emails. A receipt (and license key email) to the buyer, a sale alert to you (Emails).
-
Webhooks:
order.paid,checkout.completed,entitlement.grantedand, when a key was issued,license.created(Webhooks). -
The extension refreshes. The SDK in your service worker polls while the checkout tab is open and refreshes with backoff (1s, 2s, 4s up to 60s) when the tab reaches success or closes. With the optional
externally_connectableentry, the success page pings the extension and the refresh is instant.bill.onPaid()then fires once in every context (Checking access).
Success page and closing the tab
The success state shows the order number, the product name, the license key (if any) and your success message from Settings → Checkout.
Sessions opened from the SDK use the close_tab return behavior: a button closes the tab and returns to your extension, and the SDK treats the close as a signal to refresh. With return behavior none, the page stays on the success state.
Access never depends on the success page loading. It depends on the capture, which ExtensionBill confirms on its own (see Buyer closes the tab after approving).
Edge cases
Pending capture (eCheck)
Some funding sources, such as eCheck, don’t clear instantly and PayPal returns the capture as PENDING:
- The order is
pending, the page shows processing, and no access is granted yet. - When funds clear (
PAYMENT.CAPTURE.COMPLETED), the order becomespaidand the normal workflow runs. - If PayPal denies it (
PAYMENT.CAPTURE.DENIED), the order becomesfailedandorder.payment_failedis sent.
The extension picks up the change on its next refresh (startup, the background alarm or bill.refresh()).
Declined payment
On a decline (capture DENIED or INSTRUMENT_DECLINED) the API returns 402 payment_declined, the page lets the buyer retry with another funding source, and order.payment_failed is sent. Nothing is granted.
Buyer closes the tab after approving
PayPal still sends CHECKOUT.ORDER.APPROVED. If the session is still waiting on a capture, ExtensionBill captures the order from that webhook, so an approved payment is never left uncaptured. The buyer gets the receipt and access as usual.
Abandoned checkout reminder
Off by default. Turn on Abandoned checkout in Settings → Emails (emails.abandonedCheckout). Then:
- The details step shows a consent checkbox; the reminder is sent only when the buyer ticks it.
- If the buyer entered an email, ticked the box and has not completed checkout 1 hour later, ExtensionBill sends one reminder.
- The email links back to the same session, which works while it is open (up to 24 hours after creation).
Switching between one-time and subscription
A one-time purchase can’t become a subscription, or the reverse. The buyer completes a new checkout for the other price. When moving from a subscription to lifetime, also cancel the subscription so it doesn’t renew. Changing between recurring prices is a different flow: see Subscription lifecycle.
Statuses
Checkout session statuses
| Status | Meaning |
|---|---|
open | Waiting for the buyer. Plan, details and discount can still change. |
processing | A PayPal payment is in flight or the capture is pending. |
completed | Paid (or subscription approved). Linked to the order or subscription. Paying again returns 409 checkout_completed. |
expired | 24 hours passed without completion. Open a new session. |
canceled | Canceled; it can’t be paid. |
Order statuses
| Status | Meaning | Access |
|---|---|---|
pending | Capture pending at PayPal (for example an eCheck). | None yet |
paid | Capture completed and verified. | Granted |
failed | PayPal denied the payment. | None |
partially_refunded | Part of the payment was refunded. | Kept by default |
refunded | The full amount was refunded. | Revoked |
reversed | PayPal reversed the payment (chargeback or dispute lost). | Revoked |
Refunds and reversals: Refunds & disputes.
Reconciliation
For every paid order ExtensionBill stores the PayPal fee and your net amount from PayPal’s seller_receivable_breakdown, in minor units of the order currency:
{
"id": "66f2b7d91c0e4a5f8b3c2d10",
"number": "EB-LX2K9Q4",
"receiptNumber": "EB-LX2K9Q4",
"status": "paid",
"productName": "Pro",
"priceType": "one_time",
"amounts": {
"subtotal": 2900,
"discount": 0,
"tax": 0,
"total": 2900,
"currency": "USD"
},
"paypalFee": 150,
"net": 2750,
"refundedAmount": 0,
"paypalOrderId": "5O190127TN364715T",
"paypalCaptureId": "3C679366HH908993F",
"paidAt": "2026-10-12T09:41:07.000Z"
}
The fee is illustrative; the real value is whatever PayPal charged.
Overview totals gross revenue, PayPal fees, refunds and net per date range, in your app’s primary currency, with other currencies listed separately. For line-level exports, filter Orders by status and date or call GET /v1/orders (Server API).