Skip to content

Instantly share code, notes, and snippets.

@dcomartin
Created May 12, 2026 13:50
Show Gist options
  • Select an option

  • Save dcomartin/49b790f3be68bfba5c434620a0996ff6 to your computer and use it in GitHub Desktop.

Select an option

Save dcomartin/49b790f3be68bfba5c434620a0996ff6 to your computer and use it in GitHub Desktop.
public async Task Handle(int orderId, decimal amount)
{
try
{
await _paymentGateway.Capture(orderId, amount);
}
catch (TimeoutException)
{
if (await _paymentGateway.MaybeCaptured(orderId) == false)
{
await RetryLater(orderId);
}
}
catch (PaymentProviderException ex)
{
if (ex.Code == "DUPLICATE_REQUEST")
{
await CheckProviderState(orderId);
}
else if (ex.Code == "UNKNOWN")
{
await FlagForManualReview(orderId);
}
else
{
await CompensateInventory(orderId);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment