/** The fields of `billing.subscription` the cancel flow reads. */ export declare interface CancelableSubscription { readonly status: string; /** ISO instant a scheduled cancellation takes effect, else null. */ readonly cancelAt: string | null; /** ISO instant the paid period ends. */ readonly currentPeriodEnd: string | null; } /** The plan id + redirect URLs a checkout needs. */ export declare interface StartCheckoutInput { readonly plan: string; readonly successUrl: string; readonly cancelUrl: string; } /** * The caller injects the rpc binding — the generated client's * `billing.startCheckout` action. Kept as a plain function type so the web * subpath has zero dependency on the rpc client package; the app wires its * generated binding in. */ export declare type StartCheckoutRpc = (input: StartCheckoutInput) => Promise<{ readonly url: string; }>; /** The generated `billing.cancel` / `billing.resume` action bindings. */ export declare type SubscriptionActionRpc = (input: Record) => Promise; /** * React hook that drives provider-hosted checkout. Pass the generated * `billing.startCheckout` rpc binding; the hook tracks pending/error and * performs the redirect on success. * * ```tsx * const { startCheckout, pending } = useStartCheckout(rpc.billing.startCheckout) * * ``` */ export declare const useStartCheckout: (rpc: StartCheckoutRpc) => UseStartCheckoutResult; export declare interface UseStartCheckoutResult { /** Kick off checkout: calls the rpc, then redirects to the provider URL. */ readonly startCheckout: (input: StartCheckoutInput) => Promise; /** True while the rpc is in flight. */ readonly pending: boolean; /** The last error, or null. */ readonly error: Error | null; } /** * The two-step cancellation an app renders on its own billing page: an entry, * then a separate confirmation that names the end date, then — once scheduled — * the way back. The cancellation itself is the provider's period-end cancel * (`billing.cancel`); the subscription stays active until it ends. * * The state comes from the subscription the app already reads, so a * cancellation made in the provider's portal shows here too. * * ```tsx * const flow = useSubscriptionCancel({ subscription, cancel: rpc.billing.cancel, resume: rpc.billing.resume }) * flow.stage === 'active' && * flow.stage === 'confirming' && <>

Ends on {flow.endsOn}

* flow.stage === 'scheduled' && * ``` */ export declare const useSubscriptionCancel: (input: { readonly subscription: CancelableSubscription; readonly cancel: SubscriptionActionRpc; readonly resume: SubscriptionActionRpc; }) => UseSubscriptionCancelResult; export declare interface UseSubscriptionCancelResult { /** * - `active` — nothing scheduled; show the entry ("cancel your subscription here") * - `confirming` — the separate confirmation step; show `endsOn`, "cancel now" and "keep" * - `scheduled` — cancelled, ends on `endsOn`; show "take it back" * - `ended` — the subscription has ended; nothing to offer */ readonly stage: 'active' | 'confirming' | 'scheduled' | 'ended'; /** When the subscription ends (scheduled) or would end (confirming), ISO. */ readonly endsOn: string | null; /** Open the confirmation step. Calls nothing. */ readonly begin: () => void; /** Leave the confirmation step. Calls nothing. */ readonly keep: () => void; /** The confirmed cancellation — at period end, reversible until then. */ readonly confirm: () => Promise; /** Take a scheduled cancellation back. */ readonly resume: () => Promise; readonly pending: boolean; /** The last failure, or null. The subscription is unchanged when set. */ readonly error: Error | null; } export { }