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
| // Adaptador HTTP do callback do parceiro: Published Language do parceiro -> Translator -> nosso caso de uso | |
| [ApiController] | |
| [Route("callbacks/payments")] | |
| public sealed class PartnerPaymentsCallbackController : ControllerBase | |
| { | |
| private readonly PaymentAclTranslator _translator; | |
| private readonly IApplyPaymentSettlement _apply; | |
| public PartnerPaymentsCallbackController(PaymentAclTranslator translator, IApplyPaymentSettlement apply) | |
| { |
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; |
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 sealed class PlaceOrderUseCase : IPlaceOrderUseCase | |
| { | |
| private readonly IOrderRepository _orders; | |
| private readonly IPaymentGateway _payments; | |
| public PlaceOrderUseCase(IOrderRepository orders, IPaymentGateway payments) | |
| { | |
| _orders = orders; | |
| _payments = payments; | |
| } |
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
| // Gateway concreto (borda): detalhe periférico; usa o Translator | |
| public sealed class PartnerPaymentGateway : IPaymentGateway | |
| { | |
| private readonly HttpClient _http; | |
| private readonly PaymentAclTranslator _t; | |
| public PartnerPaymentGateway(HttpClient http, PaymentAclTranslator t) | |
| { | |
| _http = http; | |
| _t = t; |
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
| // DTOs do PARCEIRO (exemplos fictícios) | |
| public sealed record PartnerAuthDto(string Id, string Ccy, string Gross); | |
| public sealed record PartnerAuthResponse(string Status, string AuthCode); // ex.: "APPROVED" | "DECLINED" | "PENDING" | |
| public sealed record PartnerSettlementDto(string Id, string FinalStatus, string? AuthCode); // ex.: "SETTLED" | "REJECTED" | |
| // Translator da ACL: parceiro <-> nosso modelo | |
| public sealed class PaymentAclTranslator | |
| { | |
| public PartnerAuthDto ToPartner(PaymentRequest req) => |
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
| // Porta de saída para iniciar o pagamento (sincronia do nosso lado; resultado pode ser PENDING) | |
| public interface IPaymentGateway | |
| { | |
| PaymentAuthorization Authorize(PaymentRequest request); | |
| } | |
| // Porta de entrada (callback/notificação) para receber a liquidação (eventual consistency) | |
| public interface IPaymentSettlementHandler | |
| { | |
| void Apply(PaymentSettlementNotification notification); |
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
| // Adaptador HTTP (fino): só HTTP; delega para a mesma Facade | |
| [ApiController] | |
| [Route("api/orders")] | |
| public sealed class OrdersController : ControllerBase | |
| { | |
| private readonly OrdersFacade _facade; | |
| public OrdersController(OrdersFacade facade) => _facade = facade; | |
| [HttpPost] | |
| public ActionResult<PlaceOrderResponseDto> Post([FromBody] PlaceOrderRequestDto dto) |
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
| // Published Language (DTOs públicos do nosso Open Host Service) | |
| public sealed record PlaceOrderRequestDto( | |
| string CustomerCode, | |
| string Currency, | |
| IReadOnlyList<PlaceOrderItemDto> Items); | |
| public sealed record PlaceOrderItemDto(string Sku, int Quantity, decimal UnitPrice); | |
| public sealed record PlaceOrderResponseDto( | |
| string OrderNumber, |