// Package payments owns customer quotation ownership and durable execution intent. // Money and settlement remain authoritative in the provider. package payments import ( "context" "time" customer "git.sendico.io/tech/sxchnge/product/customers/model" "git.sendico.io/tech/sxchnge/shared/database/record" "go.mongodb.org/mongo-driver/v2/bson" ) type Account struct { ID, Currency string Precision int Available int64 PayoutMethod, PayoutLabel, FundingMethod string } type Request struct { Kind, Source, Destination, Recipient string Amount int64 } type Quote struct { ID string Request Request Fee, Debit, Credit int64 ExpiresAt time.Time RateNumerator, RateDenominator int64 } type Operation struct { ID string Quote Quote Status string CreatedAt time.Time } type Snapshot struct { Accounts []Account Operations []Operation } type Record struct { storable.Base `bson:",inline"` Customer bson.ObjectID `bson:"customer"` Namespace string `bson:"namespace"` Subject string `bson:"subject"` Quote Quote `bson:"quote"` ProviderQuote string `bson:"providerQuote"` Key string `bson:"key"` Payment string `bson:"payment"` } func (*Record) Collection() string { return "payment_quotes" } type Provider interface { Namespace() string Accounts(context.Context, string) ([]Account, error) Quote(context.Context, string, Request, []Account) (Quote, error) Execute(context.Context, string, string) (RemoteOperation, error) Payment(context.Context, string) (RemoteOperation, error) } type RemoteOperation struct { ID, QuoteRef, Status string CreatedAt time.Time } type Identity interface { Subject(context.Context, *customer.Account) (string, error) } type Failure string func (e Failure) Error() string { return string(e) } const ( Unavailable Failure = "unavailable" InvalidAmount Failure = "invalidAmount" InvalidRecipient Failure = "invalidRecipient" InsufficientFunds Failure = "insufficientFunds" LimitExceeded Failure = "limitExceeded" ExpiredQuote Failure = "expiredQuote" Unsupported Failure = "unsupported" NotFound Failure = "notFound" Uncertain Failure = "uncertain" FactorRequired Failure = "factorRequired" )