Integrating with Stripe

This page assumes that you already have a Stripe account created and are able to create plans. To sign-up and create a Stripe account, visit the Stripe website.

Prerequisites

In order to integrate Stripe with Moesif, there are a few prerequisites which must be completed. These include:

  1. Creating an account with Stripe
  2. Creating a plan in Stripe

The plan must be set with price details set to be recurring and usage is metered must be set to true. It is also recommended that the charge for metered usage by field be set to sum of usage values during period and each price have a price description filled out.

Here is an example configuration for a pricing item in Stripe:

Example

Configuring the Stripe integration

Moesif’s connection with Stripe involves 2-way communication. Moesif has created a simple way to get all the info you need and to configure certain variables for Stripe in a single screen.The Stripe setup details screen can be accessed a few ways, including:

Through Settings > Extensions

Example

and then selecting install on the Stripe extension

Example

Through the Billing Meters screen Edit Billing Providers dropdown

Example

And through the Create New Billing Meter screen

Example

Once you’ve opened the configuration screen through one of the routes above, you can get the info needed to add the Moesif Webhook to Stripe, inputs to plug the Stripe API into Moesif, and customize your Customer ID source in a single place.

Adding the Moesif Webhook to Stripe

In Stripe, a Webhook needs to be added so that Stripe can send subscription updates to Moesif. To do this you’ll need to make sure you are logged into your Stripe account. Once logged in, use the left-side menu to navigate to the Developer button in the top menu.

Example

Once you’re on the Developers page click on Webhooks in the left-side menu. Then, Click on the Add an endpoint button near the bottom of the screen.

Example

On the Listen to Stripe events screen that appears after clicking the Add an endpoint button, paste in the Webhook URL into the Endpoint URL field. Optionally, add a description for the endpoint.

These details can be found in Moesif by clicking the Edit Billing Provider dropdown on the Billing Meters screen or by going to Settings > Extensions > Stripe and clicking install.

Example

The Endpoint URL value you add to Stripe should also contain your Moesif Application ID. The generated URL in the Moesif installation page will already contain the correct Application ID and have it appended to the URL.

You’ll also need to configure the endpoint to listen to all events. To do this, you’ll click on the Select events button.

Example

And then you’ll check off Select all events and click Add events at the bottom of the page.

Example

Lastly, click Add endpoint at the bottom of the screen (again, you’ll likely need to scroll to the bottom of the page). The Webhook should then be created and display on the Webhooks screen in Stripe.

Example

Now, your added Webhook should then be created and display on the Webhooks screen in Stripe.

Example

Configuring the Stripe extension in Moesif

In Moesif, you will need to plug in the Stripe API details so that Moesif can post usage details to Stripe to bill upon. These details can be entered into the Stripe API Version and Stripe API Key fields on the Stripe Setup Details screen.

Currently, Moesif only supports v3 of the Stripe API.

The Stripe Private API Key can be found in Stripe by navigating to the Developers screen and clicking on API Keys from the left-side menu.

Example

Next, you can either use the Secret key or create a Restricted key if you need more fine-tuned control over access.

To reveal the Secret key, click the Reveal key button.

Example

This will then display your key.

You may also be prompted to enter your password if the account has been inactive for a while

Example

Note: this example is done using test keys. To get a production key, toggle View testing data to switch over to production-mode to view production keys.

Copy the value listed under Secret key or your Restricted key and paste it into the Stripe API Key field on the Stripe Setup Details screen.

Example

Once completed, be sure to click Save.

Customizing the Customer ID source

The Customize Customer ID Source configuration on the Stripe Setup Details screen allows users to specify the Stripe subscription and customer field that Moesif will use as the Moesif company id and Moesif user id respectfully.

Example

Linking a plan in Stripe to a billing meter

When creating a new billing meter, in the Link To section you can specify Stripe as the Billing Provider and then select the Product and Price you’d like the usage to be linked to.

Example

Updated: