Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Nov 6, 2025

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/)

    • Project file with proper package metadata and tags
    • StripeResource - ContainerResource for Stripe CLI
    • StripeExtensions - Comprehensive extension methods
    • Complete README with correct API usage examples
    • Fixed documentation for events parameter to reflect IEnumerable
  • Test Package (tests/CommunityToolkit.Aspire.Hosting.Stripe.Tests/)

    • Unit tests covering all extension methods
    • Integration tests for the example AppHost
    • Added to CI workflow
  • Example Application (examples/stripe/)

    • AppHost project demonstrating webhook forwarding
    • Sample API project with webhook endpoint
    • All projects added to solution file
  • Code Quality Improvements

    • Fixed README examples to use ExternalService instead of plain strings
    • Updated events parameter documentation to clarify array syntax
    • Added explicit Where filters to foreach loops per code review

Recent Fixes (Latest Commit)

  • Fixed README examples on lines 84-86 and 97 to use AddExternalService instead of plain string URLs
  • Updated events parameter in examples from comma-separated string to array syntax: ["event1", "event2"]
  • Corrected XML documentation for events parameter from "comma-separated list" to "collection"
  • Added explicit Where filters to foreach loops in StripeExtensions.cs and RequiresAuthenticatedToolDiscoverer.cs
Original prompt

This section details on the original issue you should resolve

<issue_title>Hosting integration for Stripe CLI</issue_title>
<issue_description>### Related to an existing integration?

No

Existing integration

No response

Overview

It would be a valuable addition to the Aspire ecosystem to include a built-in integration for the Stripe CLI. When working locally, the Stripe CLI is essential for simulating webhooks, managing test data, and interacting with the Stripe API in real time. Embedding this functionality into Aspire as a hosting extension would streamline the developer experience by reducing manual setup and enabling better orchestration of services. This could significantly improve productivity and consistency across environments, especially for teams building payment-enabled applications. A native Aspire extension for Stripe CLI would align well with Aspire’s goal of simplifying cloud-native development through composable and observable service models.

Usage example

var stripe = builder.AddStripeLocal("stripe")...

var api = builder.AddProject<Projects.API>("api")
                   .WithReference(stripe);

Extra: commands on the resource to trigger sample requests.

Breaking change?

I'm not sure

Alternatives

$ stripe listen --forward-to http://localhost:5082/payments/stripe-webhook

Additional context

There's an article that touches the topic by @julioct

https://juliocasal.com/blog/how-to-build-custom-net-aspire-hosting-extensions-with-stripe-cli-example
https://juliocasal.com/blog/speed-up-your-stripe-dev-loop-with-net-aspire

I could help implementing this solution but I wouldn't be able to deviate too much from the blog post.

Help us help you

No, just wanted to propose this</issue_description>

Comments on the Issue (you are @copilot in this section)

Custom agent used: Hosting Integration Creator
This agent helps users create new hosting integration in Aspire by scaffolding the correct projects and files based on user input.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI changed the title [WIP] Add hosting integration for Stripe CLI Add Stripe CLI hosting integration Nov 6, 2025
Copilot AI requested a review from aaronpowell November 6, 2025 05:26
@github-actions github-actions bot added the Stale label Nov 12, 2025
@aaronpowell aaronpowell removed the Stale label Nov 12, 2025
Copilot AI and others added 4 commits November 27, 2025 00:06
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>
@aaronpowell aaronpowell force-pushed the copilot/add-stripe-cli-integration branch from 7823d96 to d4abb78 Compare November 27, 2025 00:07
@aaronpowell
Copy link
Member

@Kralizek @julioct I've finally got back to this after the latest release. What do you think of the approach? It's using the installed executable not the container version, or do you think that would be a better option?

@Kralizek
Copy link

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.

@julioct
Copy link

julioct commented Nov 27, 2025

@Kralizek @julioct I've finally got back to this after the latest release. What do you think of the approach? It's using the installed executable not the container version, or do you think that would be a better option?

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.

@aaronpowell
Copy link
Member

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.

@aaronpowell
Copy link
Member

@Kralizek @julioct any additional feedback? Otherwise it's probably good to merge in.

@aaronpowell aaronpowell marked this pull request as ready for review December 4, 2025 05:31
Copilot AI review requested due to automatic review settings December 4, 2025 05:31
Copy link
Contributor

Copilot AI left a 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

Comment on lines 84 to 86
var stripe = builder.AddStripe("stripe", apiKey)
.WithListen("http://localhost:5082/webhooks")
.WithApiKey(apiKey); // optional: forwards the key to the CLI via --api-key
Copy link

Copilot AI Dec 4, 2025

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);

Copilot uses AI. Check for mistakes.
Comment on lines 206 to 213
foreach (var line in logEvent)
{
if (TryExtractSigningSecret(line.Content, out var signingSecret))
{
resource.WebhookSigningSecret = signingSecret;
return;
}
}
Copy link

Copilot AI Dec 4, 2025

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(...)'.

Copilot uses AI. Check for mistakes.
Comment on lines 17 to 24
foreach (object? argument in traitAttribute.GetConstructorArguments())
{
if (argument is string value)
{
toolName = value;
break;
}
}
Copy link

Copilot AI Dec 4, 2025

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(...)'.

Copilot uses AI. Check for mistakes.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Member

@aaronpowell aaronpowell left a 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>
Copy link
Contributor Author

Copilot AI commented Dec 8, 2025

@copilot there's some comments on the README - can you ensure it's updated correctly with the API design

Updated the README with the correct API design. Changes in commit 4d55c0e:

  • Fixed examples to use AddExternalService instead of plain string URLs (lines 84-86, 97)
  • Updated events parameter from comma-separated strings to array syntax: ["event1", "event2"]
  • Corrected XML documentation for events parameter to reflect IEnumerable<string> type
  • Added explicit Where filters to foreach loops per code review suggestions

@github-actions
Copy link
Contributor

Code Coverage

Package Line Rate Branch Rate Complexity Health
CommunityToolkit.Aspire.GoFeatureFlag 100% 97% 74
CommunityToolkit.Aspire.Hosting.ActiveMQ 78% 40% 108
CommunityToolkit.Aspire.Hosting.ActiveMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.Adminer 74% 50% 20
CommunityToolkit.Aspire.Hosting.Azure.Dapr 29% 7% 124
CommunityToolkit.Aspire.Hosting.Azure.Dapr.Redis 61% 34% 76
CommunityToolkit.Aspire.Hosting.Azure.DataApiBuilder 100% 100% 22
CommunityToolkit.Aspire.Hosting.Bun 96% 83% 28
CommunityToolkit.Aspire.Hosting.Dapr 60% 37% 840
CommunityToolkit.Aspire.Hosting.DbGate 94% 50% 18
CommunityToolkit.Aspire.Hosting.Deno 98% 85% 44
CommunityToolkit.Aspire.Hosting.Flagd 79% 100% 32
CommunityToolkit.Aspire.Hosting.GoFeatureFlag 88% 73% 36
CommunityToolkit.Aspire.Hosting.Golang 51% 40% 88
CommunityToolkit.Aspire.Hosting.Java 70% 75% 130
CommunityToolkit.Aspire.Hosting.JavaScript.Extensions 97% 85% 200
CommunityToolkit.Aspire.Hosting.k6 58% 12% 20
CommunityToolkit.Aspire.Hosting.Keycloak.Extensions 100% 100% 22
CommunityToolkit.Aspire.Hosting.KurrentDB 71% 75% 34
CommunityToolkit.Aspire.Hosting.LavinMQ 74% 50% 26
CommunityToolkit.Aspire.Hosting.LavinMQ.MassTransit 1% 0% 14
CommunityToolkit.Aspire.Hosting.MailPit 85% 50% 22
CommunityToolkit.Aspire.Hosting.McpInspector 77% 44% 204
CommunityToolkit.Aspire.Hosting.Meilisearch 71% 57% 58
CommunityToolkit.Aspire.Hosting.Minio 88% 75% 56
CommunityToolkit.Aspire.Hosting.MongoDB.Extensions 96% 83% 36
CommunityToolkit.Aspire.Hosting.MySql.Extensions 100% 88% 78
CommunityToolkit.Aspire.Hosting.Ngrok 52% 35% 82
CommunityToolkit.Aspire.Hosting.Ollama 65% 69% 260
CommunityToolkit.Aspire.Hosting.OpenTelemetryCollector 78% 61% 77
CommunityToolkit.Aspire.Hosting.PapercutSmtp 81% 50% 18
CommunityToolkit.Aspire.Hosting.PostgreSQL.Extensions 99% 89% 84
CommunityToolkit.Aspire.Hosting.Python.Extensions 45% 29% 100
CommunityToolkit.Aspire.Hosting.RavenDB 62% 48% 148
CommunityToolkit.Aspire.Hosting.Redis.Extensions 100% 71% 48
CommunityToolkit.Aspire.Hosting.Rust 94% 83% 16
CommunityToolkit.Aspire.Hosting.Solr 72% 100% 22
CommunityToolkit.Aspire.Hosting.SqlDatabaseProjects 51% 48% 192
CommunityToolkit.Aspire.Hosting.Sqlite 89% 89% 52
CommunityToolkit.Aspire.Hosting.SqlServer.Extensions 100% 87% 78
CommunityToolkit.Aspire.Hosting.Stripe 51% 30% 82
CommunityToolkit.Aspire.Hosting.SurrealDb 55% 40% 256
CommunityToolkit.Aspire.KurrentDB 94% 92% 54
CommunityToolkit.Aspire.MassTransit.RabbitMQ 100% 100% 30
CommunityToolkit.Aspire.Meilisearch 97% 92% 68
CommunityToolkit.Aspire.Microsoft.Data.Sqlite 89% 85% 52
CommunityToolkit.Aspire.Microsoft.EntityFrameworkCore.Sqlite 61% 58% 114
CommunityToolkit.Aspire.Minio.Client 90% 85% 112
CommunityToolkit.Aspire.OllamaSharp 77% 71% 132
CommunityToolkit.Aspire.RavenDB.Client 60% 53% 237
CommunityToolkit.Aspire.SurrealDb 79% 63% 78
Summary 67% (7488 / 11104) 55% (2099 / 3794) 4816

Minimum allowed line rate is 60%

@aaronpowell aaronpowell merged commit 7cdd467 into main Dec 10, 2025
214 of 215 checks passed
@aaronpowell aaronpowell deleted the copilot/add-stripe-cli-integration branch December 10, 2025 23:58
@aaronpowell aaronpowell added this to the 13.1 milestone Dec 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hosting integration for Stripe CLI

4 participants