Skip to content

Instantly share code, notes, and snippets.

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

  • Save rcarubbi/38dfd2a33501f74ce0e7c5882b5db167 to your computer and use it in GitHub Desktop.

Select an option

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