Logo

Get Started

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

Check out the video below to see the Stripe app in action:

1. Install the Stripe App

To install 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.

2. Connect a Stripe Customer

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

  1. Manually Provide Stripe Customer ID: Set the Stripe Customer ID and Payment Method ID.
  2. Create a Checkout Session: Get a Stripe Checkout URL via the OpenMeter API.

2.1. Connect an Existing Stripe Customer

To connect an existing Stripe customer to an OpenMeter customer, you can do so in the customer details page in OpenMeter or via the API.

Default Payment Method

Be sure that you also set the Stripe Default Payment Method ID in OpenMeter or to set a default payment method in Stripe for the customer. This is necessary to automatically charge the customer when an invoice is created.

Node.js Example

await openmeter.customers.stripe.upsert('customer-id-or-key', {
  stripeCustomerId: 'cus_123',
  // Optionally set the default payment method
  // stripeDefaultPaymentMethodId: 'pm_123',
});

cURL Example

curl  -X PUT \
  'https://dev.openmeter.cloud/api/v1/customers/01JDJM1WF8Y461YQ9F0EW4WHY2/stripe' \
  --header 'Accept: */*' \
  --header 'Authorization: Bearer my-token' \
  --header 'Content-Type: application/json' \
  --data-raw '{
    "stripeCustomerId": "cus_123"
  }'
Stripe Checkout Session

Use the Stripe Checkout Session to collect payment details create a Stripe Customer automatically.

2.2. Create a Checkout Session

OpenMeter provides a simple API to create a customer and generate a Stripe Checkout link to collect payment details. With a single API call you can:

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

The response will contain a URL to the Stripe checkout form to collect credit card details.

When a customer completes the checkout form and provides their payment method, OpenMeter will automatically set the Stripe Customer ID and the payment method to the default payment method for the OpenMeter customer. This is done via OpenMeter listening to the setup_intent.succeeded event via webhooks. This webhook is setup automatically when the OpenMeter Stripe App is installed.

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"
  }
}'

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

Last updated on