Idempotent payment webhooks in golang with an event table
Payment providers like Razorpay deliver webhooks at least once. Verify the signature on the raw body, record each event in a Postgres table with a unique (provider, event_id), process it in the same transaction and check the captured amount before settling.