Created
September 12, 2025 23:22
-
-
Save rcarubbi/92af90a68735048a7d67b3e2058c3387 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
| // Caso de uso/serviço interno para aplicar a liquidação (chamado pelo callback) | |
| public interface IApplyPaymentSettlement | |
| { | |
| void Apply(PaymentSettlementNotification notification); | |
| } | |
| public sealed class ApplyPaymentSettlement : IApplyPaymentSettlement, IPaymentSettlementHandler | |
| { | |
| private readonly IOrderRepository _orders; | |
| public ApplyPaymentSettlement(IOrderRepository orders) => _orders = orders; | |
| public void Apply(PaymentSettlementNotification notification) | |
| { | |
| var order = _orders.GetByNumber(notification.OrderNumber) ?? throw new InvalidOperationException("Order not found"); | |
| if (notification.Status == PaymentSettlementStatus.Settled) | |
| order.MarkPaid(notification.Code); | |
| else | |
| order.MarkPaymentFailed(notification.Code); | |
| _orders.Save(order); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment