Subscription and billing actions
Billing and plans: checkFeatureAccessAction server action and tRPC routers for Stripe, subscriptions, cards, orders, and Worker Node purchases.
dFlow Cloud billing uses Stripe. The UI combines Server Actions for a few checks with tRPC routers for plans, payment methods, checkout, and Worker Node orders.
Server action
actionName | Source | Permission keys (from getActionAccess) |
|---|---|---|
checkFeatureAccessAction | packages/core/src/actions/subscription/index.ts | servers.read |
Use this page together with customer docs under Billing and Account under Billing and Account in the sidebar for behaviour and UX.
tRPC: subscription plans
Router: subscriptions on appRouter (packages/cloud/src/trpc/routers/subscriptionPlans/index.ts).
Notable procedures include:
| Procedure | Access | Role |
|---|---|---|
getPlans | publicProcedure | Marketing / pricing surfaces that list plans without a session. |
getUserSubscriptionPlan | userProcedure | Current subscriber state for the signed-in user. |
getAddonUsage | userProcedure | Add-on consumption. |
getSubscriptionPreview | userProcedure | Proration and change previews. |
createFreeSubscription | userProcedure | Free tier onboarding. |
updateSubscription | userProcedure | Plan changes and upgrades. |
getSubscriptionDetails | userProcedure | Detailed subscription payload. |
cancelDowngradeSchedule | userProcedure | Cancel a scheduled downgrade. |
The file contains additional helpers and mutations; inspect the router for the full list.
tRPC: Stripe customer and payment methods
Router: stripe (packages/cloud/src/trpc/routers/stripe/index.ts).
| Procedure | Role |
|---|---|
createStripeCustomer | Ensure a Stripe customer exists. |
getStripeCustomer | Fetch Stripe customer. |
getSubscriptionPreview | Invoice preview for selected prices. |
createSetupIntent | Add a card (SetupIntent). |
hasDefaultPaymentMethod | Whether default payment method is set. |
attachPaymentMethod | Attach a payment method to the customer. |
getPaymentMethods | List saved methods. |
updateDefaultPaymentMethod | Set default. |
deletePaymentMethod | Remove a method. |
cancelSubscription | Cancel at period end for a Stripe subscription id. |
addWalletAmount | Wallet top-up checkout session. |
tRPC: saved cards (Billing payment methods)
Router: card (packages/cloud/src/trpc/routers/card/index.ts).
| Procedure | Role |
|---|---|
addNewCard | Add card metadata the UI persists. |
getCards | List cards. |
updateCardName | Rename. |
deleteCard | Remove. |
tRPC: orders
Router: orders (packages/cloud/src/trpc/routers/orders/index.ts).
| Procedure | Role |
|---|---|
getAllOrders | List orders for the user. |
tRPC: Worker Node / VPS purchases
Router: vpsOrders (packages/cloud/src/trpc/routers/vpsOrders/index.ts).
Examples include createOrder, getOrders, getOrdersById, getSubscriptions, lifecycle stopServer, startServer, restartServer, refetchServerStatus, and subscription management such as cancelServerSubscription, resumeServerSubscription, cancelOrResumeWorkerNodeAtMonthEnd. Read the router for exact inputs and side effects.
Related tRPC routers
Billing and growth flows also touch coupons, rewards, discord, workerNodes (for example a getServersWithFieldsAction query backed by Payload), vpsPlans, and cloud. Explore packages/cloud/src/trpc/routers/index.ts for the authoritative router list.
Learn more
- Billing overview and Plans and subscriptions.
- API overview for where
/api/trpcis served. - tRPC and backend reference for context and client usage.