Logo

Stripe

Beta

OpenMeter Apps is currently in Beta.

The Stripe app integrates OpenMeter with Stripe to provide additional features and seamlessly integrate with existing workflows. For example, the Stripe app can be configured to synchronize invoices to Stripe, calculate tax, and collect payments automatically.

Get Started

To get started with the Stripe app, follow these steps:

  1. Go to Stripe App in the OpenMeter dashboard.
  2. Click on the Install button.
  3. Follow the authorization steps to connect the app with OpenMeter.
  4. Optionally configure the billing profile to use the Stripe app.

What does the Stripe app do?

The Stripe app integrates OpenMeter with the following Stripe products:

  • Stripe Tax: Calculate taxes automatically via Stripe based on location, product, or other criteria.
  • Stripe Invoicing: Sync and deliver invoices via Stripe and collect payments.
  • Stripe Payments: Collect payments via Stripe payment gateway using multiple payment methods.

Stripe Tax

Leverage Stripe Tax to handle complex tax rules and rates for any region. The integration ensures accurate, up-to-date tax calculations for each invoice, removing the guesswork and reducing compliance risks.

Stripe calculates tax based on:

  • Vendor location
  • Customer location
  • Product tax code (global default or per rate card)
Defining Tax Codes

To define tax codes for rate cards, you can set default tax codes in Billing Settings. You can also specify tax codes per rate card by editing the product catalog when creating a plan.

Stripe Invoicing

Stripe Invoicing is a global invoicing software platform built to save you time and get you paid faster. OpenMeter can synchronize invoices to Stripe Invoicing continuesly to automatically collect payments. Stripe Invoicing makes it easy to automate accounts receivable, collect payments, and reconcile transactions.

Stripe Payments

Collect payments quickly and securely via Stripe's trusted payment gateway. Your customers can choose from various payment methods—credit card, ACH, and more—to improve the overall customer experience and speed up cash flow.

In OpenMeter you can configure the default payment method and currency to use for payments per customer and billing profile.

Integrating With Stripe

In OpenMeter there are two ways to onboard customers to Stripe for payments:

  1. Manually Set Stripe Customer ID: Set the Stripe Customer ID and Payment Method ID. (see below)
  2. Simplified Checkout Experience: Create a Stripe Checkout URL via the OpenMeter API. (see below)
Customer Default Payment Method

When you add a payment method to a customer in OpenMeter, that method becomes the default. However, if you leave the payment method field in OpenMeter blank, OpenMeter will fall back to the default payment method set in Stripe (if any).

1. Manually Set Stripe Customer ID

To manually set the Stripe customer ID and payment method for a customer, you can do so in the customer details page in OpenMeter or via the API.

Node.js Example

The upsert method is used to create or update app data for a customer. It accepts an array of app data objects, each representing a different app.

await openmeter.customers.app.upsert('my-openmeter-customer-id', [
  {
    type: 'stripe',
    stripeCustomerId: 'cus_xxxxxxx',
 
    // Optional, default will be used if not provided
    // Useful if you have multiple apps and want to specify the app
    // appId: 'xxxxx',
 
    // Optional: payment method, if not provided, the default payment method in Stripe will be used
    // Required if there is no default payment method in Stripe
    // stripeDefaultPaymentMethodId: 'pm_xxxxxxx',
  },
]);

cURL Example

curl  -X PUT \
  'https://dev.openmeter.cloud/api/v1/customers/01JDJM1WF8Y461YQ9F0EW4WHY2/apps' \
  --header 'Accept: */*' \
  --header 'User-Agent: Thunder Client (https://www.thunderclient.com)' \
  --header 'Authorization: Bearer my-token' \
  --header 'Content-Type: application/json' \
  --data-raw '[
  {
    "type": "stripe",
    "stripeCustomerId": "cus_xxxxxxx"
  }
]'

2. Simplified Checkout Experience

To simplify onboarding customers and collecting payments, OpenMeter provides a simple API to create a customer and generate a Stripe Checkout link. With a single API call you can:

  • Create an OpenMeter Customer (or use an existing one)
  • Attribute Metered Usage to the customer
  • Create a Stripe customer (or use an existing one)
  • Generate a Stripe Checkout URL to the payment form

Node.js Example

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',
  },
});

Wich will return a URL to the Stripe checkout form to collect credit card details:

{
  "customerId": "01JKHFVVZ71HGXD25E28PG8F5Z",
  "mode": "setup",
  "sessionId": "cs_test_xxx",
  "setupIntentId": "seti_xxx",
  "stripeCustomerId": "cus_xxx",
  "successURL": "https://example.com/success",
  "url": "https://checkout.stripe.com/c/pay/cs_test_xxx"
}

cURL Example

Example API Request:

curl  -X POST \
  'https://openmeter.cloud/api/v1/stripe/checkout/sessions' \
  --header 'Authorization: Bearer my-token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
  "customer": {
    "name": "ACME, Inc.",
    "currency": "USD",
    "usageAttribution": { "subjectKeys": ["my-identifier"] }
  },
  "options": {
    "successUrl": "https://example.com/success"
  }
}'

You'll receive a Stripe Checkout Session URL in response, ready to securely capture payment information.

model CreateStripeCheckoutSessionResult {
  customerId: ULID;
  stripeCustomerId: string;
  sessionId: string;
  setupIntentId: string;
  url: string;
  mode: StripeCheckoutSessionMode;
  cancelURL?: string;
  successURL?: string;
  returnURL?: string;
}

See the Stripe Checkout API documentation for more details on the response fields.