Skip to main content

Monetizing TeaQL in Public — Day 6: A Cancellation Screen That Can Say ‘Not Confirmed Yet’

· 8 min read
Philip Z
Architect

A cancellation button needs to explain more than whether a request succeeded. The user needs to know when renewal stops, what happens to paid access, and what to do when the response disappears after the server accepts the command.

On Day 5, we implemented the backend preview and confirmation API. Today we connect it to the shared TypeScript console and verify the interaction in an actual local browser.

This is a local fixture demonstration, not a real Paddle Sandbox run. The screenshots use synthetic accounts, real IAM sessions, and local TeaQL/SQLite services. An injected provider simulates cancellation and a lost response. No real subscription was canceled and no refund was issued. Real Paddle Sandbox checkout, cancellation, and public HTTPS delivery remain unverified.

Start with the user journey​

Alex owns Acme. Sam has its Finance role. Morgan is a Developer. Acme already has Plus from a locally signed payment fixture; another Organization stays Free.

Alex opens cancellation review. The screen shows the provider's current period end and the recorded paid-access end. Alex can keep renewal unchanged without submitting a cancellation.

Sam opens the same review and explicitly confirms. Our demo provider accepts the cancellation and deliberately loses the response. The screen makes one status read, finds the schedule, and shows the confirmed date. Morgan retains Plus access and has no financial cancellation controls.

The browser network trace contains exactly one cancellation POST. Reviewing, dismissing, and checking status are reads or local UI actions.

Show a date before offering confirmation​

We added a small cancellation section inside the authorized billing card. It is shown only when a subscription is recorded and the user has subscription management permission. An Organization with no recorded subscription does not get a cancellation control.

The first action is Review cancellation. It fetches the current provider state. A response that says renewal is not scheduled to stop opens a confirmation with the exact period-end date, displayed in UTC:

Finance reviews the date and keeps paid access visible in the local demo

The two choices are Confirm stop renewal and Keep renewal unchanged. The latter only dismisses the preview. The confirmation explains that paid access remains until its recorded end and that this action does not request a refund. It does not imply that a separate refund request is unavailable.

A confirmation sends only the affirmative decision and displayed period end:

{ confirm: true, expectedPeriodEnd }

The existing Day 5 service rechecks that date and the Organization binding before contacting the provider. A changed period clears the frontend preview and requires another review. The browser cannot choose immediate cancellation, a provider customer, or a subscription ID.

Reuse the domain contract behind the screen​

There is no new model or schema in Day 6. We reused the Day 5 API and generated library without evaluation or regeneration. All 41 retained generated-source hashes still match their original manifest.

The unchanged backend resolves its provider subscription through the authorized Organization. Its Q query remains bounded and declares its business purpose:

const subscription = await Q.subscriptionRecords()
.filterByOrganizationAccount(String(account.id))
.limit(1)
.comment('Read cancellation subscription binding')
.purpose('Derive provider resources from the authorized Organization')
.executeForOne(context);

The complete E expression reads the saved provider binding:

const subscriptionId = String(
E.subscriptionRecord(subscription).providerSubscriptionKey().eval()
);

Paid validity comes from the existing entitlement, separately from cancellation state:

const paidAccessUntil = entitlement
? E.organizationEntitlement(entitlement).validUntil().eval()
: null;

These are reused backend operations, not new client-side database queries. The frontend receives the small scoped API response. It never receives provider credentials or uses payment state to grant itself a role.

Give uncertainty its own state​

The cancellation controller uses explicit phases:

PhaseUser action or meaning
IdleReview cancellation
LoadingRead provider state; no command is being sent
ConfirmReview the returned date and explicitly confirm or dismiss
SubmittingOne command is in flight; duplicate confirmation is blocked
Scheduled / canceledDisplay confirmed provider state; offer a status check
UncertainStatus is not confirmed; offer a read rather than a repeat command
ErrorExplain the problem and require a new review where appropriate

After an uncertain command error, the controller makes one automatic status read. It never retries the POST. If that read also fails, it stops and offers Check cancellation status. There is no unbounded polling loop.

If readback reports no scheduled cancellation, the screen returns to review with an explanation. It does not silently re-arm the old confirmation; another explicit review is required before another command can be submitted.

Session expiry returns the user to sign-in. Permission loss clears the preview and refreshes the Organization's permission decisions rather than continuing to display an actionable old confirmation.

The local browser run deliberately loses the command response. The readback still produces a confirmed schedule while paid access remains Plus:

Confirmed cancellation after the simulated lost response, with Plus access unchanged

A late response belongs to its old view​

Switching Organizations can happen while a preview or command is in flight. Aborting the browser request is useful, but a server may already have accepted the operation. Abort cannot undo that external effect.

We give the cancellation controller an immutable Organization ID and a local generation counter. Every continuation checks that the controller is still active and that the response belongs to its Organization:

private current(generation: number) {
return !this.disposed && generation === this.generation;
}

The parent billing view disposes the old cancellation controller before replacing its DOM. Disposal invalidates the generation and aborts the request. A late response cannot open a confirmation, render success, or start readback inside the new view.

The DOM tests cover A → B → A: the original A preview arrives after the user has returned to a new A view. Matching the Organization ID alone would be insufficient. The old controller has been disposed, so its response is ignored.

During a command the main refresh button is disabled. Leaving the view still disposes it; returning later requires a fresh provider read. There is no promise that navigation canceled an already accepted provider operation.

Keep permission enforcement in the backend​

The client shows controls according to its current permission decisions. The same-origin API client attaches the session and CSRF token on confirmation. It validates the returned Organization, cancellation state, schedule consistency, and recognized command outcome.

Billing still independently authorizes each operation. The backend's Finance, Origin/CSRF, provider-binding, date-conflict, and cross-Organization tests remain in the regression suite. Hiding a button does not replace those checks.

In the actual browser run, Morgan sees paid developer access without financial controls:

Developer retains Plus and has no cancellation control

Switching to the other Organization shows its own Free entitlement:

The other Organization remains Free in the local fixture demo

Preserve useful evidence without preserving the test machine​

The browser helper used a separate temporary Chrome profile and only synthetic local accounts. It retained screenshots and an allowlisted trace of cancellation request methods and paths. It did not retain cookies, session tokens, provider credentials, or a browser profile.

The interactive browser-control tool was unavailable during this session. The successful run used local headless Chrome instead, with real page JavaScript, IAM/Billing HTTP listeners, and SQLite persistence. It is distinct from the jsdom tests and from a real provider integration.

The helper waits for its own Chrome process to stop and removes its profile on exit. The local demo owns its temporary database files and removes them when stopped. It does not stop other sessions' services. Production entry points do not import the synthetic sign-in or provider controls.

Verification and remaining work​

State, DOM, transport, Billing, and IAM regressions passed. The local browser run observed no JavaScript exceptions and exactly one cancellation POST after the simulated lost response. See the verification summary and browser trace for the exact counts, scope and local-fixture boundaries.

The model and generated library were unchanged. This entry adds user interaction and local demo wiring rather than a new billing schema.

Real Paddle Sandbox cancellation and public HTTPS delivery remain pending. There is still no durable local cancellation-command/audit ledger, cancellation webhook handling, retry worker, refund flow, or re-subscribe workflow in this slice. The confirmation screen completes one part of Day 5's pending work; it does not complete the whole production billing lifecycle.

Other SaaS builders can reuse the separation between renewal and paid access, a visible unknown state, one readback instead of an automatic command retry, and view disposal that invalidates every old continuation.