When integrating Worldpay in a production ASP.NET Core application, one of the hardest problems is debugging webhook failures.
Events arrive asynchronously, logs are often missing, and issues usually appear only after a payment dispute or customer complaint.
In this article, I’ll share practical lessons from a real Worldpay integration and show how proper event logging can save hours of debugging time.
Why debugging Worldpay webhooks is hard
- Webhooks are asynchronous and hard to trace
- Failures often happen only in production
- Default logging does not capture full event context
- Disputes appear days later without history
- Retried events are difficult to correlate
A minimal webhook logging approach
// POST endpoint to log payment events
[HttpPost("log-payment")]
public async Task<IActionResult> LogPaymentEvent([FromBody] PaymentEvent paymentEvent)
{
// Log the payment event
await _paymentEventLogger.LogAsync(paymentEvent);
return Ok("Payment event logged successfully!");
}
While this approach works for basic visibility, it quickly becomes insufficient in real-world scenarios.
Important metadata such as event type, retries, timestamps, and correlation identifiers are not captured in a structured way, making audits and debugging difficult.
Improving Worldpay webhook logging
In a production environment, webhook logging needs to be more structured and reliable.
During a Worldpay integration, I implemented a dedicated event logging approach that captures:
- Full event payloads
- Event type and timestamps
- Retry attempts
- Correlation identifiers
- Storage for later audits and dispute analysis
public async Task LogAsync(PaymentEvent paymentEvent)
{
// Persist full webhook payload with metadata
await _eventStore.SaveAsync(paymentEvent);
}
new PaymentEvent
{
Provider = "Worldpay",
EventType = eventType,
Status = status,
ReferenceId = referenceId,
Payload = rawPayload,
CreatedAt = DateTime.UtcNow
};
Internally, the logger persists the complete Worldpay event payload along with metadata such as provider, event type, status, reference identifiers, and timestamps.
This makes it possible to reconstruct the full lifecycle of a payment event during audits, dispute investigations, or production incident analysis.
Source and further reading
GitHub repository (free version): https://github.com/PratheebaAnand/PaymentEventLogger
Extended version with persistence and audit features: https://ramapratheeba.gumroad.com/l/gdzkpw
Top comments (0)