Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save dcomartin/c0bd8033bd2878609a406811d78911af to your computer and use it in GitHub Desktop.
public async Task ReconcilePayment(
Guid orderId,
IMessageHandlerContext context,
CancellationToken cancellationToken)
{
var order = await _orders.Get(orderId, cancellationToken);
if (order.Status == OrderStatus.Confirmed ||
order.Status == OrderStatus.Cancelled)
{
return;
}
var status = await _payments.GetPaymentStatus(
orderId,
cancellationToken);
if (status.Captured)
{
await _orders.MarkPaymentCaptured(
orderId,
status.PaymentId!,
cancellationToken);
await context.Send(new ConfirmOrder(orderId));
return;
}
if (status.Failed)
{
await _orders.MarkPaymentFailed(
orderId,
cancellationToken);
await context.Send(new CancelOrder(
orderId,
"Payment failed"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment