-
Notifications
You must be signed in to change notification settings - Fork 154
Add Stripe CLI hosting integration #950
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
7823d96 to
d4abb78
Compare
|
Is there a specific advantage on targeting the locally installed CLI rather than leveraging the existing container? It feels like it's adding a manual step (installation of the CLI) that can be skipped altogether. |
Why not use the container? As with anything Aspire-related, the whole point is that anyone can clone the repo, hit F5, and it just works. |
|
That's a fair point - I was trying to simplify getting the signing code, but it comes at a cost of simplicity. The branch has a rewrite that uses the container version. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR adds a hosting integration for Stripe CLI to enable local webhook forwarding and testing in Aspire applications. The integration wraps the Stripe CLI in a container and provides extension methods for configuring webhook forwarding to application endpoints.
- Adds
StripeResource(ContainerResource) and extension methods for Stripe CLI configuration - Implements webhook signing secret extraction from CLI logs
- Includes comprehensive test coverage (20 unit tests, 2 integration tests, example AppHost)
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 16 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/CommunityToolkit.Aspire.Testing/RequiresAuthenticatedToolAttribute.cs | New testing attribute for marking tests requiring authenticated external tools |
| tests/CommunityToolkit.Aspire.Testing/RequiresAuthenticatedToolDiscoverer.cs | xUnit trait discoverer for the RequiresAuthenticatedToolAttribute |
| tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests.csproj | Test project configuration for Stripe integration tests |
| tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/AppHostTests.cs | Integration tests validating resource creation and health |
| tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/AddStripeTests.cs | Unit tests covering extension methods and argument configuration |
| src/CommunityToolkit.Aspire.Hosting.Stripe/StripeResource.cs | Resource definition for Stripe CLI container |
| src/CommunityToolkit.Aspire.Hosting.Stripe/StripeExtensions.cs | Extension methods for adding and configuring Stripe CLI |
| src/CommunityToolkit.Aspire.Hosting.Stripe/StripeContainerImageTags.cs | Container image configuration constants |
| src/CommunityToolkit.Aspire.Hosting.Stripe/README.md | Integration documentation and usage examples |
| src/CommunityToolkit.Aspire.Hosting.Stripe/CommunityToolkit.Aspire.Hosting.Stripe.csproj | Project configuration for hosting integration |
| examples/stripe/CommunityToolkit.Aspire.Hosting.Stripe.AppHost/Properties/launchSettings.json | Launch settings for example AppHost |
| examples/stripe/CommunityToolkit.Aspire.Hosting.Stripe.AppHost/Program.cs | Example AppHost demonstrating webhook forwarding |
| examples/stripe/CommunityToolkit.Aspire.Hosting.Stripe.AppHost/CommunityToolkit.Aspire.Hosting.Stripe.AppHost.csproj | AppHost project configuration |
| examples/stripe/CommunityToolkit.Aspire.Hosting.Stripe.Api/Properties/launchSettings.json | Launch settings for example API |
| examples/stripe/CommunityToolkit.Aspire.Hosting.Stripe.Api/Program.cs | Example API with webhook endpoint |
| examples/stripe/CommunityToolkit.Aspire.Hosting.Stripe.Api/CommunityToolkit.Aspire.Hosting.Stripe.Api.csproj | API project configuration |
| CommunityToolkit.Aspire.slnx | Solution file updated to include Stripe integration projects |
| .github/workflows/tests.yaml | CI workflow updated to include Stripe integration tests |
tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/AddStripeTests.cs
Outdated
Show resolved
Hide resolved
| var stripe = builder.AddStripe("stripe", apiKey) | ||
| .WithListen("http://localhost:5082/webhooks") | ||
| .WithApiKey(apiKey); // optional: forwards the key to the CLI via --api-key |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The example uses WithListen with a plain string URL, but there is no overload that accepts a string. The available overloads accept either IResourceBuilder<IResourceWithEndpoints> or IResourceBuilder<ExternalServiceResource>.
To fix this example:
var webhookEndpoint = builder.AddExternalService("webhook-endpoint", "http://localhost:5082");
var stripe = builder.AddStripe("stripe", apiKey)
.WithListen(webhookEndpoint, webhookPath: "/webhooks")
.WithApiKey(apiKey);| foreach (var line in logEvent) | ||
| { | ||
| if (TryExtractSigningSecret(line.Content, out var signingSecret)) | ||
| { | ||
| resource.WebhookSigningSecret = signingSecret; | ||
| return; | ||
| } | ||
| } |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
| foreach (object? argument in traitAttribute.GetConstructorArguments()) | ||
| { | ||
| if (argument is string value) | ||
| { | ||
| toolName = value; | ||
| break; | ||
| } | ||
| } |
Copilot
AI
Dec 4, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This foreach loop implicitly filters its target sequence - consider filtering the sequence explicitly using '.Where(...)'.
tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/AddStripeTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
aaronpowell
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@copilot there's some comments on the README - can you ensure it's updated correctly with the API design
Co-authored-by: aaronpowell <434140+aaronpowell@users.noreply.github.com>
Updated the README with the correct API design. Changes in commit 4d55c0e:
|
Minimum allowed line rate is |
Implementation Complete: Stripe CLI Hosting Integration
Successfully implemented a complete hosting integration for the Stripe CLI in the .NET Aspire Community Toolkit.
✅ All Tasks Completed
Integration Package (
src/CommunityToolkit.Aspire.Hosting.Stripe/)StripeResource- ContainerResource for Stripe CLIStripeExtensions- Comprehensive extension methodsTest Package (
tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/)Example Application (
examples/stripe/)Code Quality Improvements
Recent Fixes (Latest Commit)
AddExternalServiceinstead of plain string URLs["event1", "event2"]Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.