Subscription and billing actions

checkFeatureAccessAction plus tRPC routers for Stripe, plans, cards, orders, and Worker Node purchases.

Written By Zoro

Last updated 3 days ago

dFlow Cloud billing

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

actionNameSourcePermission keys (from getActionAccess)
checkFeatureAccessActionpackages/core/src/actions/subscription/index.tsservers.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:

ProcedureAccessRole
getPlanspublicProcedureMarketing / pricing surfaces that list plans without a session.
getUserSubscriptionPlanuserProcedureCurrent subscriber state for the signed-in user.
getAddonUsageuserProcedureAdd-on consumption.
getSubscriptionPreviewuserProcedureProration and change previews.
createFreeSubscriptionuserProcedureFree tier onboarding.
updateSubscriptionuserProcedurePlan changes and upgrades.
getSubscriptionDetailsuserProcedureDetailed subscription payload.
cancelDowngradeScheduleuserProcedureCancel 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).

Procedures:

createStripeCustomerEnsure a Stripe customer exists.
getStripeCustomerFetch Stripe customer.
getSubscriptionPreviewInvoice preview for selected prices.
createSetupIntentAdd a card (SetupIntent).
hasDefaultPaymentMethodWhether default payment method is set.
attachPaymentMethodAttach a payment method to the customer.
getPaymentMethodsList saved methods.
updateDefaultPaymentMethodSet default.
deletePaymentMethodRemove a method.
cancelSubscriptionCancel at period end for a Stripe subscription id.
addWalletAmountWallet top-up checkout session.

tRPC: saved cards (dashboard โ€œCardsโ€)

Router: card (packages/cloud/src/trpc/routers/card/index.ts).

addNewCardAdd card metadata the UI persists.
getCardsList cards.
updateCardNameRename.
deleteCardRemove.

tRPC: orders

Router: orders (packages/cloud/src/trpc/routers/orders/index.ts).

getAllOrdersList 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