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

go
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:
    }
}

Learn this concept

Lesson 8.3 · HMAC webhooks and payment sagas

Used in exercises

Exercise 8.4 · Payment processing service