An internal-linking app built by an agency to insert product links into blog posts went through this on its way to the Shopify App Store. Its compliance and billing fixes ran through 2026-02-05 (from the project inventory). This post covers the mechanics those fixes sit on, and the credit accounting behind the paid features is covered in the ledger post.
How does Shopify app billing work?
The flow is a redirect exchange between three parties, and the app’s job is to make each step idempotent. Access should never depend on the browser coming back.
- The merchant chooses a plan. The app maps the choice to a plan name and a price object it already knows.
- The app creates the charge. It calls
appSubscriptionCreatewith the line items, the interval and areturnUrl, and receives aconfirmationUrlplus the new subscription id. - The merchant approves or declines on Shopify. The app redirects the top-level browser to the confirmation URL. Shopify hosts this page; the app never sees card data.
- Shopify redirects to the return URL. On approval it goes to the app’s
returnUrl. On decline it sends the merchant to the admin with a notification, which is a path many apps forget to handle. - The app reads the subscription back. It queries the current installation’s active subscriptions and compares the result to the plan it expected.
- The app grants or refuses access. Only an active subscription grants access to paid features, and the check runs on every request that needs it, not just once after the redirect.
mutation CreateAnnualPlan($amount: Decimal!, $returnUrl: URL!) {
appSubscriptionCreate(
name: "Annual plan"
returnUrl: $returnUrl
replacementBehavior: STANDARD
lineItems: [{
plan: {
appRecurringPricingDetails: {
price: { amount: $amount, currencyCode: "USD" }
interval: ANNUAL
}
}
}]
) {
confirmationUrl
appSubscription { id }
userErrors { field message }
}
}
The mutation makes annual billing a one-line difference. What changes is everything around it: how plans are keyed, how upgrades behave, and what the merchant sees in the charge history.
Why annual pricing is a separate code path
Annual pricing changes the plan identity, the renewal date, the proration maths and when the next charge appears.
Four things have to line up:
- The interval is part of the plan. A catalogue keyed only by name treats monthly and annual as one plan and overwrites one with the other; the key needs the interval.
- Replacement behaviour is explicit. When a merchant already has a subscription,
replacementBehaviordecides whether the old one is replaced now or after the current period. The default isSTANDARD; leaving it implicit means the behaviour is whatever that default happens to be at review time. - The charge history has to be readable. Requirement 1.2.3 also asks that charges appear correctly in the merchant’s application charge history. An annual plan that creates a subscription without a readable charge line looks like a billing error to a reviewer.
- Upgrades and downgrades must work without a reinstall. The app has to offer the change in its own UI and route it through the Billing API. Requiring a support ticket is a review failure, not a product preference.
The upgrade path has one more trap. A merchant who upgrades from monthly to annual should see one prorated charge, not two parallel subscriptions. The app has to replace the existing subscription deliberately, then re-read the active list rather than assuming the newest id is the only one.
What is the offline-session billing return?
An offline access token is a shop-level credential that persists without a user session. Shopify issues offline tokens by default because apps need to work in the background: webhooks, scheduled jobs, and reconciliation. Billing is one of those background operations, because the subscription has to be checked even when nobody is looking at the app.
The return from the confirmation page is where offline sessions surprise people. The merchant approves the charge in a Shopify-hosted page, and Shopify redirects the browser to the app’s returnUrl. That request is a fresh top-level navigation. It does not carry the app’s in-memory session, and if the app relies on a session cookie set inside the embedded frame, the return can arrive looking unauthenticated.
The reliable pattern is to rebuild the context from what the return actually carries: the shop identifier, the host parameter, and the app’s own stored installation record. From there the app can load the offline token for that shop and ask Shopify what the current installation’s subscriptions are.
// The return is a fresh request: rebuild the shop context, then ask Shopify.
const shop = normalizeShop(searchParams.get("shop"));
const install = await db.installation.findUnique({ where: { shop } });
if (!install) return redirect("/install");
const session = await getOfflineSession(shop); // shop-level token
const active = await getActiveSubscriptions(session); // source of truth
if (!active.some((s) => s.planKey === install.pendingPlanKey)) {
return renderBillingPending(); // declined, closed, or not settled yet
}
await activatePlan(install.accountId, install.pendingPlanKey);
return redirect("/app?billing=active");
Three habits make the return safe. Treat it as a hint, not a receipt: the query is the receipt, because a merchant can approve and still lose the redirect. Make activation idempotent: the same return can arrive twice, or follow a timeout and a retry, so activating an active plan must be a no-op. Store the pending plan before redirecting: a pending row keyed by shop is sturdier than reconstructing the plan from a price id in the return URL.
The decline path deserves the same treatment. Shopify sends a declined merchant to the admin with a message, not to the app’s return URL. An app that only activates on approval is fine; one that treats a missing return as failure and retries the charge shows the merchant a second confirmation page.
Why the reload redirect matters
The reload redirect matters because a return page can render inside the iframe while the admin shell keeps the old state. An embedded app runs in an iframe, and App Bridge keeps the top-level URL in sync with its route; a server redirect changes the frame’s document but not the shell.
After a billing approval, that difference is visible: the app has a new subscription, but the frame may still show the old plan page, or a return page with no navigation, or a spinner that never resolves. The merchant’s next click can land on a stale route. The fix is a reload redirect: send the top-level browser to the app’s entry route after activation, so the admin reloads the app with the new billing state.
Two details make it work. Break out of the frame deliberately: use App Bridge’s navigation or an anchor with target="_top"; a server-side redirect() is not the same thing. Reload once, after the state is committed: reloading before activation produces the same stale page, and reloading on every render loops.
The reload also refreshes the session token. An embedded app authenticates each request with a token minted by App Bridge, and a full reload guarantees the next request carries one issued after the plan change.
What App Store review checks about billing
App Store review checks billing as a set of user journeys: install, charge, decline, approve, change plan and uninstall. The review exercises the journeys below, so each one has to work without a support ticket.
| Requirement | What the reviewer does | What has to be true |
|---|---|---|
| 1.2.1 Shopify billing only | Looks for external checkout links or invoices | All charges go through Shopify App Pricing or the Billing API |
| 1.2.2 Accept, decline, re-request | Declines a charge, then retries | Decline is handled, and the app can ask again on reinstall |
| 1.2.3 Plan changes | Upgrades or downgrades in the app | The change goes through the Billing API without support or a reinstall |
| 3.1.2 Expiring offline tokens | Installs and exercises background features | Admin API calls use expiring offline tokens, not non-expiring ones |
| 4.2.1 Pricing accuracy | Compares the listing to the in-app pricing | Prices, trials and charge details match the listing exactly |
| 2.1.1 No critical errors | Follows the main path end to end | The billing redirect does not dead-end or loop |
Every requirement is a user journey, not a feature. An app can implement appSubscriptionCreate perfectly and still fail 1.2.3 because the upgrade button is missing from its settings page.
Comparison: three ways to charge for a Shopify app
| Method | Allowed on the App Store | Merchant experience | App’s job |
|---|---|---|---|
| Shopify Billing API (Manual Pricing) | Yes | Charge appears on the Shopify invoice | Create charges, handle returns, gate features |
| Shopify App Pricing | Yes, and the default for new public apps | Shopify hosts plan selection and billing | Configure plans in the Partner Dashboard |
| Stripe or direct invoicing | No | Separate invoice and card entry | Everything, plus a policy violation |
Which should you choose?
Use Shopify App Pricing for a new public app with a supported pricing model: it is the current default and removes the billing code entirely. Use the Billing API when you need a charge type the hosted model does not cover, or when an existing integration already works. Do not use Stripe or direct invoicing for App Store distribution; requirement 1.2.1 makes it ineligible.
What broke and what we changed
Annual pricing was missing from the path. A billing flow built around monthly plans has no interval to carry, so annual plans need their own path through plan selection, the charge and the read-back. The fix that shipped was annual pricing end to end: the interval carried through plan selection, the charge, and the read-back that gates access.
The return from Shopify arrived outside the app session. The approval redirect is a top-level navigation back from a Shopify-hosted page, so it cannot assume the embedded session is still intact. The fix was the offline-session billing return: rebuild the shop context from the return parameters, load the shop’s offline token, and read the active subscription before granting anything.
The post-approval screen rendered inside the frame. A return page rendered in the iframe leaves the admin shell and the app disagreeing about the plan, with no admin navigation. The fix was the reload redirect: activate and commit, then send the top-level browser back to the app so the admin reloads the frame with the new state.
A plan change is a billing event, not a settings toggle. Create the new subscription, wait for approval, then read the active subscription and update the app. The reverse order leaves a merchant on a plan they are not paying for.
Related
Frequently asked questions
Does a Shopify app have to use Shopify's billing?
Yes, for App Store distribution. Requirement 1.2.1 says apps with charges must use Shopify App Pricing or the Billing API, and off-platform billing cannot be listed. The rule gives merchants one invoice and one dispute path. Direct Stripe billing is only viable for a private app that is not listed.
What does appSubscriptionCreate return?
It returns the new subscription's id and a confirmationUrl where the merchant approves or declines the charge, plus a list of user errors. The app redirects the merchant to the confirmation URL. On approval, Shopify redirects to the returnUrl the app supplied; on decline, the merchant goes back to the admin with a notification.
Why does the return from billing lose the session?
Because it is a top-level navigation from a Shopify-hosted page, not a request inside the embedded frame, so the app's in-memory session may not apply. Rebuild the shop context from the return parameters, load the shop's offline token, and query the active subscription instead of trusting the redirect.
What is an offline access token in Shopify?
It is a shop-level credential that persists without a user session, used for webhooks and background jobs; online tokens are scoped to a staff member's session. Public apps must use expiring offline tokens, so the app needs a refresh path.
What is a reload redirect in an embedded Shopify app?
It is a redirect that reloads the top-level admin view, not only the app's iframe. After approval, the app activates and commits, then navigates the top-level browser back so App Bridge reinitialises and reads the new state. Without it, the frame can show a stale page with no admin navigation.
Can a merchant upgrade without reinstalling?
They must be able to: requirement 1.2.3 makes it a condition of listing. In practice the app shows the available plans, creates a new subscription with a deliberate replacement behaviour, and re-reads the active subscriptions after the approval. The merchant should never need to contact support or uninstall to change plan.
