package gateway import ( "errors" "testing" "time" "github.com/tech/sendico/gateway/mntx/internal/service/monetix" "github.com/tech/sendico/pkg/merrors" mntxv1 "github.com/tech/sendico/pkg/proto/gateway/mntx/v1" ) func requireReason(t *testing.T, err error, reason string) { t.Helper() if err == nil { t.Fatalf("expected error") } if !errors.Is(err, merrors.ErrInvalidArg) { t.Fatalf("expected invalid argument error, got %v", err) } reasoned, ok := err.(payoutFailure) if !ok { t.Fatalf("expected payout failure reason, got %T", err) } if reasoned.Reason() != reason { t.Fatalf("expected reason %q, got %q", reason, reasoned.Reason()) } } func testMonetixConfig() monetix.Config { return monetix.Config{ AllowedCurrencies: []string{"RUB", "USD"}, } } func validCardPayoutRequest() *mntxv1.CardPayoutRequest { return &mntxv1.CardPayoutRequest{ PayoutId: "payout-1", CustomerId: "cust-1", CustomerFirstName: "Jane", CustomerLastName: "Doe", CustomerIp: "203.0.113.10", AmountMinor: 1500, Currency: "RUB", CardPan: "4111111111111111", CardHolder: "JANE DOE", CardExpMonth: 12, CardExpYear: 2035, } } func validCardTokenPayoutRequest() *mntxv1.CardTokenPayoutRequest { return &mntxv1.CardTokenPayoutRequest{ PayoutId: "payout-1", CustomerId: "cust-1", CustomerFirstName: "Jane", CustomerLastName: "Doe", CustomerIp: "203.0.113.11", AmountMinor: 2500, Currency: "USD", CardToken: "tok_123", } } func validCardTokenizeRequest() *mntxv1.CardTokenizeRequest { month, year := futureExpiry() return &mntxv1.CardTokenizeRequest{ RequestId: "req-1", CustomerId: "cust-1", CustomerFirstName: "Jane", CustomerLastName: "Doe", CustomerIp: "203.0.113.12", CardPan: "4111111111111111", CardHolder: "JANE DOE", CardCvv: "123", CardExpMonth: month, CardExpYear: year, } } func futureExpiry() (uint32, uint32) { now := time.Now().UTC() return uint32(now.Month()), uint32(now.Year() + 1) }