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

Create integration tests that use the Stripe webhook handler to configure a plan #267

Open
travis opened this issue Nov 7, 2023 · 0 comments

Comments

@travis
Copy link
Contributor

travis commented Nov 7, 2023

It would be nice to have a test for our Stripe integration. I think this can be added to the existing integration test flow in test/integration.test.js, but we will need to coordinate webhook signing secrets and call into the billing service for the first time, so I think it will take a bit of work to do properly. The following is a rough outline of how I think this should work:

  1. we will need to add an additional step to setupNewClient that uses stripe.webhooks.generateTestHeaderString to create a signed webhook request
  2. we'll need to POST that signed request to the billing service's new /stripe endpoint - this will require us to teach setupNewClient about the billing service, since it uses a different HTTP endpoint than the upload API we've interacted with thus far
  3. we'll need to ensure that the test environment's secrets are configured with a STRIPE_ENDPOINT_SECRET matching the secret used to create the signed webhook request in step (1) - this probably means adding a STRIPE_ENDPOINT_TEST_SECRET (name flexible) to the process.env of the integration test and ensuring that the two match. We'll want to be careful to avoid leaking secrets if possible here.
  4. we'll need to ensure that the REQUIRE_PAYMENT_PLAN environment variable is set to true in the integration environment.
travis added a commit that referenced this issue Nov 7, 2023
Most of the heavy lifting here is done by upgrading the `@web3-storage/upload-api` dependency. There is a new "feature flag" in the context that changes whether payment plans are required for provisioning - I'm going to set it to `false` for now in production and we can flip it once we're ready to turn this on.

I spent a bit of time working toward extending our integration tests to exercise the Stripe webhook handler, but it turned into a big enough project that I decided to defer and recorded what I learned in an issue here:

#267
travis added a commit that referenced this issue Nov 8, 2023
Most of the heavy lifting here is done by upgrading the
`@web3-storage/upload-api` dependency. There is a new "feature flag" in
the context that changes whether payment plans are required for
provisioning - I'm going to set it to `false` for now in production and
we can flip it once we're ready to turn this on.

I spent a bit of time working toward extending our integration tests to
exercise the Stripe webhook handler, but it turned into a big enough
project that I decided to defer and recorded what I learned in an issue
here:

#267
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

No branches or pull requests

1 participant