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.
In order to integrate Stripe with Moesif, there are a few prerequisites which must be completed. These include:
- Creating an account with Stripe
- 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:
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
and then selecting install on the Stripe extension
Through the Billing Meters screen Edit Billing Providers dropdown
And through the Create New Billing Meter screen
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.
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.
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.
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.
And then you’ll check off Select all events and click Add events at the bottom of the page.
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.
Now, your added Webhook should then be created and display on the Webhooks screen in Stripe.
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.
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.
This will then display your key.
You may also be prompted to enter your password if the account has been inactive for a while
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.
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.
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.