Description of your new file.
So far we have focused on how to create subscriptions where a constant amount is charged on a recurring basis (eg. $9/month). Often, however, it is quite useful to be able to charge customers for their actual usage (eg. how many times they have used a certain feature). This is where metered usage feature can be helpful.
If you have used Cryptolens without the recurring payment module, it was most likely implemented using data objects. In the recurring payment module, all usage tracking is taken care of by Stripe, so a different method needs to be used.
Before continuing reading, please go through all the steps in the setup tutorial. It is assumed that you already have a product in Stripe and that you are familiar with how plans work.
When you create a plan, you can choose between recurring quantity
or metered usage
. For this tutorial, the metered usage
option needs to be selected.
Most of the settings don’t need to be changed; we will cover the important ones below:
Note: it’s important to create a metadata field with the properties of the license key, as described here.
To record usage, we can use Record Usage method. It will call Stripe’s metered usage API and increment the current value with the provided amount. All you need is to create an access token with Subscription
permission and provide a license key with a product id.
Description of your new file.
So far we have focused on how to create subscriptions where a constant amount is charged on a recurring basis (eg. $9/month). Often, however, it is quite useful to be able to charge customers for their actual usage (eg. how many times they have used a certain feature). This is where metered usage feature can be helpful.
If you have used Cryptolens without the recurring payment module, it was most likely implemented using data objects. In the recurring payment module, all usage tracking is taken care of by Stripe, so a different method needs to be used.
Before continuing reading, please go through all the steps in the setup tutorial. It is assumed that you already have a product in Stripe and that you are familiar with how plans work.
When you create a plan, you can choose between recurring quantity
or metered usage
. For this tutorial, the metered usage
option needs to be selected.
Most of the settings don’t need to be changed; we will cover the important ones below:
Note: it’s important to create a metadata field with the properties of the license key, as described here.
To record usage, we can use Record Usage method. It will call Stripe’s metered usage API and increment the current value with the provided amount. All you need is to create an access token with Subscription
permission and provide a license key with a product id.