CommunityToolkit.Aspire.Hosting.Stripe
13.4.0
Prefix Reserved
See the version list below for details.
dotnet add package CommunityToolkit.Aspire.Hosting.Stripe --version 13.4.0
NuGet\Install-Package CommunityToolkit.Aspire.Hosting.Stripe -Version 13.4.0
<PackageReference Include="CommunityToolkit.Aspire.Hosting.Stripe" Version="13.4.0" />
<PackageVersion Include="CommunityToolkit.Aspire.Hosting.Stripe" Version="13.4.0" />
<PackageReference Include="CommunityToolkit.Aspire.Hosting.Stripe" />
paket add CommunityToolkit.Aspire.Hosting.Stripe --version 13.4.0
#r "nuget: CommunityToolkit.Aspire.Hosting.Stripe, 13.4.0"
#:package CommunityToolkit.Aspire.Hosting.Stripe@13.4.0
#addin nuget:?package=CommunityToolkit.Aspire.Hosting.Stripe&version=13.4.0
#tool nuget:?package=CommunityToolkit.Aspire.Hosting.Stripe&version=13.4.0
CommunityToolkit.Aspire.Hosting.Stripe library
Provides extension methods and resource definitions for an Aspire AppHost to configure the Stripe CLI for local webhook forwarding and testing.
Getting Started
Prerequisites
The Stripe CLI must be installed on your machine. You can install it by following the official Stripe CLI installation guide.
Install the package
In your AppHost project, install the package using the following command:
dotnet add package CommunityToolkit.Aspire.Hosting.Stripe
Example usage
Then, in the Program.cs file of your AppHost project, add the Stripe CLI and configure it to forward webhooks to your API:
var builder = DistributedApplication.CreateBuilder(args);
var stripeApiKey = builder.AddParameter("stripe-api-key", "sk_test_default", secret: true); // Override for real keys
var externalEndpoint = builder.AddExternalService("webhook-endpoint", "http://localhost:5082");
var stripe = builder.AddStripe("stripe", stripeApiKey)
.WithListen(externalEndpoint, webhookPath: "/payments/stripe-webhook");
var api = builder.AddProject<Projects.API>("api")
.WithReference(stripe);
builder.Build().Run();
This will:
- Start the Stripe CLI listening for webhook events
- Forward all webhook events to
http://localhost:5082/payments/stripe-webhook - Provide the Stripe API key to the container via the
STRIPE_API_KEYenvironment variable - Make the webhook signing secret available to the API project via the
STRIPE_WEBHOOK_SECRETenvironment variable
Forwarding to an Aspire endpoint
You can also construct URLs dynamically using Aspire endpoint references:
var builder = DistributedApplication.CreateBuilder(args);
var api = builder.AddProject<Projects.API>("api")
.WithHttpEndpoint(port: 5082, name: "http");
var stripeApiKey = builder.AddParameter("stripe-api-key", "sk_test_default", secret: true);
var stripe = builder.AddStripe("stripe", stripeApiKey)
.WithListen(api, webhookPath: "/payments/stripe-webhook",
events: ["payment_intent.created", "charge.succeeded"]);
api.WithReference(stripe);
builder.Build().Run();
Note: When constructing URLs with paths, you need to use ReferenceExpression.Create to combine the endpoint URL with your webhook path.
Using a custom environment variable for the webhook secret
By default, the webhook signing secret is exposed as STRIPE_WEBHOOK_SECRET. You can customize this:
var api = builder.AddProject<Projects.API>("api")
.WithReference(stripe, webhookSigningSecretEnvVarName: "STRIPE_SECRET");
Configuring API key
AddStripe requires an IResourceBuilder<ParameterResource> that supplies your Stripe API key. The value is exposed to the container as the STRIPE_API_KEY environment variable. You can optionally reuse the same parameter to add the --api-key command-line argument:
var apiKey = builder.AddParameter("stripe-api-key", "sk_test_default", secret: true);
var webhookEndpoint = builder.AddExternalService("webhook-endpoint", "http://localhost:5082");
var stripe = builder.AddStripe("stripe", apiKey)
.WithListen(webhookEndpoint, webhookPath: "/webhooks")
.WithApiKey(apiKey); // optional: forwards the key to the CLI via --api-key
Filtering events
You can filter which webhook events the Stripe CLI listens for:
var stripeApiKey = builder.AddParameter("stripe-api-key", "sk_test_default", secret: true);
var webhookEndpoint = builder.AddExternalService("webhook-endpoint", "http://localhost:5082");
var stripe = builder.AddStripe("stripe", stripeApiKey)
.WithListen(webhookEndpoint, webhookPath: "/webhooks",
events: ["payment_intent.created", "charge.succeeded"]);
How it works
The Stripe CLI integration:
- Runs
stripe listen --forward-to <url>to listen for webhook events from Stripe's test environment - Forwards those events to your local application endpoint
- Exposes the webhook signing secret so your application can verify webhook authenticity
- Provides a development-friendly way to test webhook integrations without deploying to production
Additional Information
For more information about the Stripe CLI:
https://learn.microsoft.com/dotnet/aspire/community-toolkit/hosting-stripe
Feedback & contributing
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Aspire.Hosting (>= 13.4.0)
-
net8.0
- Aspire.Hosting (>= 13.4.0)
-
net9.0
- Aspire.Hosting (>= 13.4.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 13.4.1-beta.685 | 36 | 7/9/2026 |
| 13.4.1-beta.683 | 35 | 7/9/2026 |
| 13.4.1-beta.680 | 40 | 7/7/2026 |
| 13.4.1-beta.676 | 37 | 7/7/2026 |
| 13.4.1-beta.675 | 44 | 7/6/2026 |
| 13.4.1-beta.674 | 64 | 7/6/2026 |
| 13.4.0 | 1,439 | 6/2/2026 |
| 13.4.0-beta.671 | 45 | 7/3/2026 |
| 13.4.0-beta.654 | 58 | 6/18/2026 |
| 13.4.0-beta.651 | 61 | 6/17/2026 |
| 13.3.0 | 362 | 5/14/2026 |
| 13.2.1-beta.604 | 56 | 5/14/2026 |
| 13.2.1-beta.532 | 161 | 3/13/2026 |
| 13.2.1-beta.531 | 72 | 3/11/2026 |
| 13.2.1-beta.528 | 62 | 3/5/2026 |
| 13.1.2-beta.518 | 128 | 2/17/2026 |
| 13.1.2-beta.516 | 87 | 2/9/2026 |
| 13.1.2-beta.515 | 72 | 2/2/2026 |
| 13.1.2-beta.514 | 70 | 1/30/2026 |
| 13.1.2-beta.513 | 74 | 1/29/2026 |