This HTTP API sample shows how to implement usage based billing with Stripe and ASP.NET Core.
The application uses the fixed fee and overage pricing model for subscriptions. A fixed fee is charged upfront and the overage fee is charged at the beginning of the next billing cycle.
- .NET SDK 9.0 or later
 - Stripe account & Stripe CLI
 - Docker
 - (Optional) Task
 
- Add your Stripe Secret key to the Recipe.Api's appsettings.Development.json file.
 - Run the App Host project
 
All of the recipe resource endpoints are secured with an access token. The application will bootstrap a default set of
users, but you can register your own with the POST /auth/register endpoint. Here's a sample payload:
{
  "email": "demo@demo.com",
  "password": "demo",
  "FullName": "Demo User"
}You can generate an access token for a user by calling the POST /auth/authenticate endpoint with the following request:
POST /connect/token
Content-Type: application/x-www-form-urlencoded
grant_type=password&username=demo@demo.com&password=demoAvailable endpoints
POST /api/recipes- Create a recipeGET /api/recipes/random- Retrieve a random recipeGET /api/recipes/latest- Retrieve the latest recipesGET /api/recipes/category/{category}- Retrieve all recipes in a categoryGET /api/recipes/code/{lookupCode}- Retrieve a recipe with the specified lookup codeDELETE /api/recipes/code/{lookupCode}- Remove a recipe with the specified lookup code
If you install the Task task runner, you can run the following operations against the project using the syntax task <task-name>.
For example, task requests:generate will generate a configurable number of request traffic to the API.
requests:authenticate - Get and set an access token for the API
  task requests:authenticaterequests:generate - Generate requests to the API
  task requests:generate