Reconciliation Loop
A reconciliation loop is a periodic background job that checks unsettled records against an authoritative source of truth and applies the necessary updates to repair discrepancies. In this course, a goroutine periodically queries the payment provider for payments that remain PENDING and are older than five minutes, then settles them using the same transition logic as webhook processing.
Minimal example
ticker := time.NewTicker(2 * time.Minute)
defer ticker.Stop()
for {
if err := reconcile(ctx); err != nil {
log.Printf("reconciliation failed: %v", err)
}
select {
case <-ctx.Done():
return
case <-ticker.C:
}
}