stripe-apps icon indicating copy to clipboard operation
stripe-apps copied to clipboard

Improvements to local development flow for webhooks

Open dan-massey opened this issue 1 year ago • 2 comments

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 avatar Sep 27 '24 20:09 dan-massey