Created
September 12, 2025 23:20
-
-
Save rcarubbi/38dfd2a33501f74ce0e7c5882b5db167 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
| // 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) => | |
| new(req.OrderNumber, req.Currency, req.Amount.ToString("F2", CultureInfo.InvariantCulture)); | |
| public PaymentAuthorization FromPartner(PartnerAuthResponse r) => | |
| r.Status switch | |
| { | |
| "APPROVED" => new PaymentAuthorization(PaymentAuthStatus.Approved, r.AuthCode), | |
| "DECLINED" => new PaymentAuthorization(PaymentAuthStatus.Declined, r.AuthCode), | |
| _ => new PaymentAuthorization(PaymentAuthStatus.Pending, r.AuthCode), | |
| }; | |
| public PaymentSettlementNotification FromSettlement(PartnerSettlementDto s) => | |
| s.FinalStatus switch | |
| { | |
| "SETTLED" => new PaymentSettlementNotification(s.Id, PaymentSettlementStatus.Settled, s.AuthCode), | |
| _ => new PaymentSettlementNotification(s.Id, PaymentSettlementStatus.Rejected, s.AuthCode), | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment