Skip to content
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

Improvements to local development flow for webhooks #988

Open
dan-massey opened this issue Sep 27, 2024 · 2 comments
Open

Improvements to local development flow for webhooks #988

dan-massey opened this issue Sep 27, 2024 · 2 comments
Assignees
Labels
feature-request "Wouldn't it be cool if I could...?" needs-triage

Comments

@dan-massey
Copy link

dan-massey commented Sep 27, 2024

Is your feature request related to a problem? Please describe.
As far as I can figure out, it isn't possible to develop and test webhook endpoints locally which need to receive connected account events.

For example, if I have a Stripe App that has a backend hosted elsewhere, to develop views locally I can run stripe apps start --manifest stripe-app.dev.json. Requests can be sent to a server running on localhost and it's easy to do iterative development because both my server and the Stripe App hot reload as I'm working.

For my webhook endpoint, running on localhost, I can send events using the Stripe CLI, but these are not Connect Webhooks but they are missing the account field that would be present in a deployed app.

So, instead, to test my webhook endpoint the steps I have to follow are:

  • Switch my app manifest to "distribution_type": "public"
  • Create a new Stripe Account (because my current account already has a public app) and stripe login to it through the CLI
  • Go through the registration/verification flow (providing business details, etc.)
  • Deploy my locally developed endpoint server to server/the cloud, seed databases etc
  • Update my app manifest CSP with my new URLs
  • Upload my app (stripe apps upload) and wait for the upload to be processed (this is usually very quick!)
  • Create a new test release
  • Create a new Stripe account to test in (no need to register/verify, I'm only going to use this in Test mode)
  • Install the app in test mode
  • Set up a new Connect type Webhook Endpoint in my new Stripe Account from the second step (because I need to hit the same DB as the installed app is using -- in the cloud -- rather than do local testing)

Then for every iteration I need to redeploy my backend and re-upload the Stripe App, generate a new installation link, reinstall the app, etc.

Describe the solution you'd like

  • It would be great to have better documentation of the correct workflow for testing App Webhook Endpoints
  • When I run stripe apps start --manifest stripe-app.dev.json it would be great if the app was installed and ran in a different (test) account to the account where the app is uploaded (perhaps one I could specify), so that events generated in the test account could be received by a Webhook Endpoint in the Platform account
  • Alternatively, being able to run stripe apps upload with a CSP that allows calls to localhost would be great, because that would at least mean I didn't have to redeploy my backend to the cloud.

Describe alternatives you've considered

  • I tried to create a Connected Account through the dashboard
@dan-massey dan-massey added feature-request "Wouldn't it be cool if I could...?" needs-triage labels Sep 27, 2024
@benhodes-stripe benhodes-stripe self-assigned this Sep 30, 2024
@benhodes-stripe
Copy link

Makes sense and is very much less than ideal. Are there any other settings beyond webhooks that you're looking to test between versions?

@dan-massey
Copy link
Author

Thanks for taking a look @benhodes-stripe

One other possible improvement to the webhook flow:

  • If it were possible to use stripe listen --forward-to localhost:/webhook to forward my webhook to my local dev server and stripe trigger {{EVENT_NAME}} with some flags to trigger a Connected Account event (even though everything is happening on one account), that would also solve the problem I think.

The only other related challenge is then testing frontend development, when the frontend is displaying values that have been generated by my backend in response to the webhooks. Because these events are related to the test account where I have run my external test, I can't run stripe apps start in that account as I'm making changes. So that also means that for each iteration I need to upload a new version and set it as being used for the external test (rather than hot reloading).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request "Wouldn't it be cool if I could...?" needs-triage
Projects
None yet
Development

No branches or pull requests

2 participants