-
-
Save dcomartin/c0bd8033bd2878609a406811d78911af to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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