max / makenotwork
| 1 | -- Pending refunds queue: stores charge.refunded webhook data when no matching |
| 2 | -- completed transaction exists yet (out-of-order webhook delivery). |
| 3 | -- |
| 4 | -- The scheduler checks for matches periodically and escalates stale entries. |
| 5 | |
| 6 | ( |
| 7 | id UUID PRIMARY KEY DEFAULT gen_random_uuid, |
| 8 | payment_intent_id TEXT NOT NULL, |
| 9 | amount BIGINT NOT NULL, |
| 10 | amount_refunded BIGINT NOT NULL, |
| 11 | created_at TIMESTAMPTZ NOT NULL DEFAULT NOW, |
| 12 | matched_at TIMESTAMPTZ, |
| 13 | escalated_at TIMESTAMPTZ |
| 14 | ); |
| 15 | |
| 16 | |
| 17 | ON pending_refunds (payment_intent_id) |
| 18 | WHERE matched_at IS NULL; |
| 19 |