Logo

Get Started

Beta

OpenMeter Billing is currently in Beta.

Implementing and maintaining pricing and packaging can be frustrating and time-consuming for developers. OpenMeter is designed to help you define plans and provision custom deals on the dashboard and onboard customers using the API or the UI quickly.

Getting Started

To get started with OpenMeter billing, follow these steps:

Setup Metering

Define your Pricing

Install the Stripe App

Onboard a Customer

Onboard a Customer

You can onboard customers using the API or the dashboard. We recommend onboarding customers using the API when they register to your application.

You can read more about how to attribute usage to customers in the subject assignment.

Free Plan

Many applications offer a free tier to their customers. As free plans don't require payment method, you can start a subscription for the customer directly by following the steps below:

Create a Customer

const customer = await openmeter.customers.create({
  name: 'ACME, Inc.',
  // Optional: make lookup easier
  key: 'my-database-id',
  usageAttribution: {
    // The subject in the usage event
    subjectKeys: ['my-usage-event-subject'],
  },
});
 
// console.log(session.url)
// https://checkout.stripe.com/c/pay/cs_test_xxxx

Start a Subscription

// After redirected to session.successURL
await openmeter.subscriptions.create({
  name: 'my-subscription',
  customerId: customer.id,
  plan: { key: 'pro' },
  activeFrom: new Date(),
});

All Set! 🎉

OpenMeter will provision all the entitlements to the customer based on the plan you assigned.

Free Plans don't require a payment method

OpenMeter doesn't allow to create a paid subscription without a payment method.

Checkout the next section to start paid subscriptions with Stripe.

If you plan to use Stripe to collect payments from your customers, you can use our simplified Stripe Simplied Checkout Experience.

Stripe App

Make sure you create a plan and install the Stripe App before you proceed.

Create a Stripe Checkout Session

This will return a URL to the Stripe checkout form to collect credit card details.

const session = await openmeter.apps.stripe.createCheckoutSession({
  customer: {
    name: 'ACME, Inc.',
    // Optional: make lookup easier
    key: 'my-database-id',
    usageAttribution: {
      // The subject in the usage event
      subjectKeys: ['my-usage-event-subject'],
    },
  },
  options: {
    // Stripe will redirect to this URL after the checkout
    successURL: 'https://example.com/success',
    currency: 'USD',
  },
});
 
// console.log(session.url)
// https://checkout.stripe.com/c/pay/cs_test_xxxx

Start a Subscription

After the customer completes the checkout, Stripe redirects the customer to the success URL. On the success URL, you can create a subscription for the customer using the OpenMeter API.

// After redirected to session.successURL
await openmeter.subscriptions.create({
  name: 'my-subscription',
  customerId: session.customerId,
  plan: { key: 'pro' },
  activeFrom: new Date(),
});

All Set! 🎉

OpenMeter will provision all the entitlements and prices for the customer based on plan you assigned. Invoices will be generated and synchronized to Stripe based on the usage events sent to OpenMeter.

Multiple Stripe accounts

In OpenMeter, you can install multiple Stripe apps with different Stripe accounts. This allows you to use different Stripe accounts and businesses for different customers.