gitpod icon indicating copy to clipboard operation
gitpod copied to clipboard

[UBP] Use a realistic event payload in Stripe webhook automated tests

Open andrew-farries opened this issue 3 years ago • 1 comments

Description

When Stripe invoices finalize, the webhook is POSTed to with an invoice.finalized payload indicating the invoice id that was finalized. The exact shape of the payload for each event type is described in the Stripe docs.

This PR make the Stripe webhook extract the invoice id from the event payload. Most of the changes are to the test code that exercises the webhook to ensure that a realistic payload is attached to the invoice.finalized event.

Related Issue(s)

Part of #10937

How to test

Automated tests for the webhook handler.

For an end to end test:

  • Run the webhook handler locally:
cd components/public-api-server/
go run . run
stripe listen --skip-verify --forward-to localhost:9002/stripe/invoices/webhook
  • Trigger some Stripe events:
stripe trigger invoice.finalized

This should start a series of Stripe events (setting up a customer and payment methods), the last of which (the invoice.finalized event) should receive a 200 OK response.

  • You should see the following in the public api server logs:
{"level":"info","message":"finalizing invoice for invoice id: in_1LUlkzGadRXm50o3jqXq7mgh","serviceContext":{"service":"public-api-server","version":""},"severity":"INFO","time":"2022-08-09T06:17:39Z"}

Release Notes

NONE

Documentation

Werft options:

  • [ ] /werft with-preview

andrew-farries avatar Aug 09 '22 06:08 andrew-farries

/hold because it's based on https://github.com/gitpod-io/gitpod/pull/11949

andrew-farries avatar Aug 09 '22 06:08 andrew-farries

/unhold

andrew-farries avatar Aug 10 '22 13:08 andrew-farries