# Database extracts (read replica, 2026-09-12 14:31 UTC)

## Query 1: the refunds on the payment

```sql
select id, amount, status, idempotency_key, request_id, created_at, updated_at
from refunds
where payment_id = 'pay_2Fw6hT9jK3sR8vN1'
order by created_at;
```

| id | amount | status | idempotency_key | request_id | created_at | updated_at |
|---|---|---|---|---|---|---|
| re_A4kT7wQ2mL9sP8xN | 8900 | succeeded | NULL | req_7Hn2kQ9wT4sL8mP3 | 2026-09-12 14:03:12.031+00 | 2026-09-12 14:03:51.601+00 |
| re_C8pW3mK6tR2sL5qY | 8900 | succeeded | NULL | req_3Wq8mL2tK7pR9sN4 | 2026-09-12 14:03:43.089+00 | 2026-09-12 14:03:51.778+00 |

## Query 2: the payment row

```sql
select id, status, amount, captured_amount, refunded_amount, updated_at
from payments
where id = 'pay_2Fw6hT9jK3sR8vN1';
```

| id | status | amount | captured_amount | refunded_amount | updated_at |
|---|---|---|---|---|---|
| pay_2Fw6hT9jK3sR8vN1 | captured | 8900 | 8900 | 17800 | 2026-09-12 14:03:51.778+00 |

## Query 3: the ledger entries

```sql
select id, kind, amount, source_event, posted_at
from ledger_entries
where payment_id = 'pay_2Fw6hT9jK3sR8vN1'
order by posted_at;
```

| id | kind | amount | source_event | posted_at |
|---|---|---|---|---|
| led_2Wq7kM3sT9pL4rN8 | capture | 8900 | evt_capture_pay_2Fw6 | 2026-09-11 16:44:11.902+00 |
| led_5Kw9mT2sQ7pL4rN8 | refund | -8900 | req_7Hn2kQ9wT4sL8mP3 | 2026-09-12 14:03:51.588+00 |
| led_8Tm2kW7sQ4pL9rN3 | refund | -8900 | req_3Wq8mL2tK7pR9sN4 | 2026-09-12 14:03:51.769+00 |

## Query 4: any payment refunded above its capture, today

```sql
select id, merchant_id, captured_amount, refunded_amount, updated_at
from payments
where refunded_amount > captured_amount
  and updated_at >= '2026-09-12 00:00+00'
order by updated_at;
```

| id | merchant_id | captured_amount | refunded_amount | updated_at |
|---|---|---|---|---|
| pay_2Fw6hT9jK3sR8vN1 | mer_B2X9L4M7 | 8900 | 17800 | 2026-09-12 14:03:51.778+00 |
| pay_6Ht4kW9mS2qL8rN3 | mer_F6G1H8J3 | 24500 | 49000 | 2026-09-12 14:03:59.131+00 |
| pay_3Kw8mT2sQ9pL7rN4 | mer_K2L7M4N9 | 5200 | 10400 | 2026-09-12 14:05:45.302+00 |

## Query 5: the same check for the previous 30 days

```sql
select count(*) from payments
where refunded_amount > captured_amount
  and updated_at between '2026-08-13 00:00+00' and '2026-09-12 00:00+00';
```

| count |
|---|
| 0 |

## Query 6: the reconciliation job history

```sql
select started_at, finished_at, duration_ms, rows_reconciled
from job_runs
where job = 'ledger_daily_reconciliation'
order by started_at desc limit 5;
```

| started_at | finished_at | duration_ms | rows_reconciled |
|---|---|---|---|
| 2026-09-12 14:00:00.214+00 | 2026-09-12 14:03:51.402+00 | 231188 | 27640 |
| 2026-09-11 14:00:00.198+00 | 2026-09-11 14:01:12.077+00 | 71879 | 6104 |
| 2026-09-10 14:00:00.221+00 | 2026-09-10 14:01:08.910+00 | 68689 | 5877 |
| 2026-09-09 14:00:00.205+00 | 2026-09-09 14:01:10.343+00 | 70138 | 5932 |
| 2026-09-08 14:00:00.187+00 | 2026-09-08 14:01:05.662+00 | 65475 | 5610 |

Note from the platform DBA on the bridge: the 12 September run reconciled the 1,842 captures replayed from the ledger dead letter queue this morning (incident NLP-4821) plus four days of backlog, hence eight times the usual rows.
