Skip to content

Instantly share code, notes, and snippets.

@rcarubbi
Created September 12, 2025 23:22
Show Gist options
  • Select an option

  • Save rcarubbi/92af90a68735048a7d67b3e2058c3387 to your computer and use it in GitHub Desktop.

Select an option

Save rcarubbi/92af90a68735048a7d67b3e2058c3387 to your computer and use it in GitHub Desktop.
// 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