/** * Gateway-level billing client — calls the Hanzo Commerce API * for subscription checks and plan lookups. * * Replaces the old IamBillingClient. All billing now goes through Commerce. */ import type { GatewayIamConfig } from "../../config/config.js"; import type { TenantContext } from "../tenant-context.js"; export type CommerceSubscription = { id?: string; planId?: string; userId?: string; status?: string; name?: string; displayName?: string; state?: string; }; export type CommercePlan = { slug?: string; name?: string; description?: string; price?: number; currency?: string; interval?: string; }; export type SubscriptionStatus = { active: boolean; subscription: CommerceSubscription | null; plan: CommercePlan | null; }; export type BillingStatus = { hasPaymentMethod: boolean; creditBalance: number; }; /** Reset caches (testing). */ export declare function resetBillingClient(): void; /** * Get the bot wallet balance from the Playground API. * Returns available USD balance in cents. Cached for 30 seconds. * Returns -1 if wallet doesn't exist (not enabled, should not gate). */ export declare function getWalletBalance(botId: string): Promise; /** * Deduct LLM usage cost from a bot wallet via the Playground API. * This is fire-and-forget — failures are logged but not thrown. * Returns true if deduction succeeded. */ export declare function deductWalletUsage(params: { botId: string; amountUsdCents: number; model?: string; provider?: string; inputTokens?: number; outputTokens?: number; cacheReadTokens?: number; cacheWriteTokens?: number; description?: string; }): Promise; /** * Check subscription status for a tenant org via Commerce API. * Results are cached for 60 seconds. */ export declare function getSubscriptionStatus(cfg: GatewayIamConfig, tenant: TenantContext, token?: string): Promise; /** * Get a plan by ID with caching via Commerce API. */ export declare function getPlan(cfg: GatewayIamConfig, planId: string, token?: string): Promise; /** * Get available balance for a user via Commerce billing API. * Returns available balance in cents. Cached for 60 seconds. */ export declare function getBalance(cfg: GatewayIamConfig, userId: string, token?: string): Promise; /** * Get combined billing status (payment method presence + credit balance). * Calls the single /billing/status endpoint to minimize round-trips. * Cached for 60 seconds. */ export declare function getBillingStatus(cfg: GatewayIamConfig, userId: string, token?: string): Promise;