Corpland Revenue

Quickstart

Create a feature and a plan, then gate an action, count it and report what it cost.

Define what you sell

In the dashboard open Plans and features. Create a metered feature called videos, then a plan free that includes 3 videos a month and turn on Give to every new customer. Add a paid plan pro at USD 15.00 a month with 30 videos.

Copy a secret key

Open API keys in Test mode and copy the secret key. Put it in your server environment as REVENUE_SECRET_KEY. Never ship it to a browser.

Install the SDK

npm install @corpland/revenue
revenue.ts
import { Revenue } from "@corpland/revenue";

export const revenue = new Revenue({ secretKey: process.env.REVENUE_SECRET_KEY });

Gate, count and report cost

render.ts
await revenue.customers.getOrCreate({ customerId: user.id, email: user.email, name: user.name });

const { allowed } = await revenue.check({ customerId: user.id, featureId: "videos" });
if (!allowed) return res.status(402).json({ message: "You have used every video on your plan" });

const video = await renderVideo();
await revenue.track({ customerId: user.id, featureId: "videos", value: 1, idempotencyKey: `render:${video.id}` });
await revenue.costs.track({ customerId: user.id, provider: "fal", featureId: "videos", amountUsd: video.cost });

check and track fail open: if Revenue is slow or down they let the customer through and log it, so a billing outage never blocks your product.

Sell the paid plan

upgrade.ts
const result = await revenue.attach({ customerId: user.id, planId: "pro", successUrl: "https://app.example.com/billing" });
if (result.paymentUrl) return res.redirect(result.paymentUrl);

The first time, the customer pays at checkout and their card is saved. After that, upgrades, renewals and extra seats charge the saved card and attach answers attached: true straight away. Show the price first with billing.preview_attach.

Building in React? The SDK ships a server handler and hooks so your billing page needs no extra endpoints. See SDK and React. Not on Node? Every call is a plain POST /v1/<operation>; see the API overview.

On this page