collab: Rework Stripe event processing (#15510)
This PR reworks how we process Stripe events for reconciliation purposes. The previous approach in #15480 turns out to not be workable, on account of the Stripe event IDs not being strictly in order. This meant that we couldn't reliably compare two arbitrary event IDs and determine which one was more recent. This new approach leans on the guidance that Stripe provides for webhooks events: > Webhook endpoints might occasionally receive the same event more than once. You can guard against duplicated event receipts by logging the [event IDs](https://docs.stripe.com/api/events/object#event_object-id) you’ve processed, and then not processing already-logged events. > > https://docs.stripe.com/webhooks#handle-duplicate-events We now record processed Stripe events in the `processed_stripe_events` table and use this to filter out events that have already been processed, so we do not process them again. When retrieving events from the Stripe events API we now buffer the unprocessed events so that we can sort them by their `created` timestamp and process them in (roughly) the order they occurred. Release Notes: - N/A
This commit is contained in:
parent
dca9400edf
commit
7c5f4b72fb
16 changed files with 242 additions and 158 deletions
|
@ -6,6 +6,8 @@ extend-exclude = [
|
|||
# File suffixes aren't typos
|
||||
"assets/icons/file_icons/file_types.json",
|
||||
"crates/extensions_ui/src/extension_suggest.rs",
|
||||
# Stripe IDs are flagged as typos.
|
||||
"crates/collab/src/db/tests/processed_stripe_event_tests.rs",
|
||||
# Not our typos
|
||||
"crates/live_kit_server/",
|
||||
# Vim makes heavy use of partial typing tables
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue