Documentation
¶
Overview ¶
Package payment owns authority-signed customer payment receipts and bounded receipt catalogs. It knows account and offering identities, exact currency, settlement time, and service period; it does not know Stripe, OGS, or any product-specific billing implementation.
Index ¶
- Constants
- type CatalogDocument
- type CatalogIssuance
- type CatalogPayload
- type CatalogVerification
- type Continuation
- type Cursor
- type Document
- type Expectation
- type Issuance
- type Payload
- type PaymentID
- type Position
- type Query
- type QueryCommitment
- type QueryDocument
- type QueryIssuance
- type QueryPayload
- type QueryRequest
- type QueryVerification
- type Selection
- type ServicePeriod
- type SigningDomain
- func (d SigningDomain) IsValid() bool
- func (d SigningDomain) MarshalJSON() ([]byte, error)
- func (d SigningDomain) MarshalText() ([]byte, error)
- func (SigningDomain) ParseCanonicalText(text []byte) (SigningDomain, error)
- func (d SigningDomain) String() string
- func (d *SigningDomain) UnmarshalJSON(data []byte) error
- func (d SigningDomain) Validate() error
- type Verification
- type Verified
- type VerifiedQuery
Constants ¶
const ( // SigningDomainReceiptV1Token separates an immutable payment receipt. SigningDomainReceiptV1Token = "primitive-payment-receipt-2026-1" // SigningDomainCatalogV1Token separates an observed payment catalog. SigningDomainCatalogV1Token = "primitive-payment-catalog-2026-1" // SigningDomainQueryV1Token separates an installed device's catalog request. SigningDomainQueryV1Token = "primitive-payment-query-2026-1" )
const ( // ReceiptPayloadJSONMaximumBytes bounds one canonical payment fact. ReceiptPayloadJSONMaximumBytes = 32 << 10 // ReceiptDocumentJSONMaximumBytes bounds one signed payment receipt. ReceiptDocumentJSONMaximumBytes = 64 << 10 )
const ( QueryPayloadJSONMaximumBytes = 32 << 10 QueryDocumentJSONMaximumBytes = 64 << 10 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CatalogDocument ¶
type CatalogDocument struct {
Payload CatalogPayload `json:"payload"`
Attestation attest.Envelope[SigningDomain] `json:"attestation"`
}
CatalogDocument carries one authority-signed receipt page.
func IssueCatalog ¶
func IssueCatalog(issuance CatalogIssuance) (CatalogDocument, error)
IssueCatalog signs one exact payment catalog page.
func (CatalogDocument) MarshalJSON ¶
func (d CatalogDocument) MarshalJSON() ([]byte, error)
MarshalJSON emits one bounded canonical signed page.
func (*CatalogDocument) UnmarshalJSON ¶
func (d *CatalogDocument) UnmarshalJSON(data []byte) error
UnmarshalJSON strictly decodes and preserves the receiver on rejection.
func (CatalogDocument) Validate ¶
func (d CatalogDocument) Validate() error
Validate closes the page, envelope, and exact signing namespace.
type CatalogIssuance ¶
type CatalogIssuance struct {
Signer crypto.Signer
Payload CatalogPayload
}
CatalogIssuance carries exact authority signing inputs for one page.
func (CatalogIssuance) Validate ¶
func (i CatalogIssuance) Validate() error
Validate closes the page and signer without issuing.
type CatalogPayload ¶
type CatalogPayload struct {
Scope receipt.Scope `json:"scope"`
Entries []Document `json:"entries"`
Watermark receipt.Watermark `json:"watermark"`
ObservedAt temporal.Instant `json:"observed_at"`
Continuation Continuation `json:"continuation"`
Request QueryCommitment `json:"query_commitment"`
}
CatalogPayload is one bounded, newest-first authority-observed receipt page.
func VerifyCatalog ¶
func VerifyCatalog(verification CatalogVerification) (CatalogPayload, error)
VerifyCatalog authenticates one exact payment page and binds it to the selection, cursor, limit, account, build, nonce, and revision requested.
func (CatalogPayload) AttestationDomain ¶
func (CatalogPayload) AttestationDomain() SigningDomain
AttestationDomain selects the payment-catalog namespace.
func (CatalogPayload) MarshalJSON ¶
func (p CatalogPayload) MarshalJSON() ([]byte, error)
MarshalJSON emits one bounded canonical payment page.
func (*CatalogPayload) UnmarshalJSON ¶
func (p *CatalogPayload) UnmarshalJSON(data []byte) error
UnmarshalJSON strictly decodes and preserves the receiver on rejection.
func (CatalogPayload) Validate ¶
func (p CatalogPayload) Validate() error
Validate closes page bounds, scope, monotonic watermark, ordering, and every embedded signed receipt structure.
func (CatalogPayload) WriteCanonical ¶
func (p CatalogPayload) WriteCanonical(destination io.Writer) error
WriteCanonical writes the exact compact signed page.
type CatalogVerification ¶
type CatalogVerification struct {
Request QueryPayload
Document CatalogDocument
TrustedKeys attest.TrustedKeys
}
CatalogVerification carries one untrusted page, its exact signed query, and caller-selected authority keys.
func (CatalogVerification) Validate ¶
func (v CatalogVerification) Validate() error
Validate closes the complete catalog verification input.
type Continuation ¶
type Continuation struct {
Cursor Cursor `json:"cursor"`
State core.CatalogContinuationState `json:"state"`
}
Continuation is a tagged union: End carries no cursor; More requires one.
func More ¶
func More(cursor Cursor) (Continuation, error)
More binds another-page state to one opaque authority cursor.
func (Continuation) MarshalJSON ¶
func (c Continuation) MarshalJSON() ([]byte, error)
MarshalJSON emits only the member owned by the selected tagged-union arm.
func (Continuation) Validate ¶
func (c Continuation) Validate() error
Validate enforces the exact tagged-union arm.
type Cursor ¶
type Cursor struct {
// contains filtered or unexported fields
}
Cursor is Payment's nominal opaque closure of one catalog position.
func NewCursor ¶
func NewCursor(value core.SHA256Digest) (Cursor, error)
NewCursor applies Payment's catalog domain to one opaque digest.
func (Cursor) MarshalJSON ¶
MarshalJSON emits the opaque digest.
func (*Cursor) UnmarshalJSON ¶
UnmarshalJSON accepts one digest and preserves the receiver on rejection.
type Document ¶
type Document struct {
Payload Payload `json:"payload"`
Attestation attest.Envelope[SigningDomain] `json:"attestation"`
}
Document carries one authority-signed immutable payment receipt.
func (Document) MarshalJSON ¶
MarshalJSON emits one bounded canonical signed receipt.
func (*Document) UnmarshalJSON ¶
UnmarshalJSON strictly decodes and preserves the receiver on rejection.
type Expectation ¶
Expectation prevents a valid receipt for another payment or tenant scope from satisfying a caller's request.
func (Expectation) Validate ¶
func (e Expectation) Validate() error
Validate closes the exact expected identity and scope.
type Payload ¶
type Payload struct {
Scope receipt.Scope `json:"scope"`
Service ServicePeriod `json:"service_period"`
Amount currency.Amount `json:"amount"`
PaidAt temporal.Instant `json:"paid_at"`
Identity PaymentID `json:"payment_id"`
}
Payload is the immutable authority statement for one settled payment.
func (Payload) AttestationDomain ¶
func (Payload) AttestationDomain() SigningDomain
AttestationDomain selects the immutable payment-receipt namespace.
func (Payload) MarshalJSON ¶
MarshalJSON emits one bounded canonical payload.
func (*Payload) UnmarshalJSON ¶
UnmarshalJSON strictly decodes and preserves the receiver on rejection.
type PaymentID ¶
type PaymentID struct {
// contains filtered or unexported fields
}
PaymentID is the authority-issued UUIDv7 for one settled customer payment.
func NewPaymentID ¶
NewPaymentID applies Payment's nominal identity boundary to a UUIDv7.
func ParsePaymentID ¶
ParsePaymentID parses one canonical UUIDv7 payment identity.
func (PaymentID) MarshalJSON ¶
MarshalJSON emits the canonical UUIDv7 string.
func (PaymentID) String ¶
String returns the canonical UUIDv7 or empty text for an invalid identity.
func (*PaymentID) UnmarshalJSON ¶
UnmarshalJSON accepts one canonical UUIDv7 and preserves the receiver on rejection.
type Position ¶
type Position struct {
Cursor Cursor `json:"cursor"`
Kind core.CatalogPositionKind `json:"kind"`
}
Position is the explicit first-page or after-cursor request arm.
func (Position) MarshalJSON ¶
MarshalJSON emits only the member owned by the selected tagged-union arm.
type Query ¶
type Query struct {
Scope receipt.Scope `json:"scope"`
Selection Selection `json:"selection"`
Position Position `json:"position"`
Limit core.CatalogPageLimit `json:"limit"`
}
Query is the complete typed input behind `receipt -all` or `receipt <id>`.
func NewQuery ¶
func NewQuery(request QueryRequest) (Query, error)
NewQuery constructs one completely typed payment catalog query.
type QueryCommitment ¶ added in v2026.0.96
type QueryCommitment struct {
// contains filtered or unexported fields
}
QueryCommitment is the non-secret domain-separated closure of one exact device-signed payment query payload.
func CommitQuery ¶ added in v2026.0.96
func CommitQuery(payload QueryPayload) (QueryCommitment, error)
CommitQuery closes the exact selection, position, scope, build, nonce, and revision without retaining the encoded query.
func (QueryCommitment) MarshalJSON ¶ added in v2026.0.96
func (c QueryCommitment) MarshalJSON() ([]byte, error)
func (*QueryCommitment) UnmarshalJSON ¶ added in v2026.0.96
func (c *QueryCommitment) UnmarshalJSON(data []byte) error
func (QueryCommitment) Validate ¶ added in v2026.0.96
func (c QueryCommitment) Validate() error
type QueryDocument ¶ added in v2026.0.56
type QueryDocument struct {
Payload QueryPayload `json:"payload"`
Attestation attest.Envelope[SigningDomain] `json:"attestation"`
}
QueryDocument carries one device signature over one exact payment query.
func IssueQuery ¶ added in v2026.0.56
func IssueQuery(issuance QueryIssuance) (QueryDocument, error)
func (QueryDocument) MarshalJSON ¶ added in v2026.0.56
func (d QueryDocument) MarshalJSON() ([]byte, error)
func (*QueryDocument) UnmarshalJSON ¶ added in v2026.0.56
func (d *QueryDocument) UnmarshalJSON(data []byte) error
func (QueryDocument) Validate ¶ added in v2026.0.56
func (d QueryDocument) Validate() error
type QueryIssuance ¶ added in v2026.0.56
type QueryIssuance struct {
Signer crypto.Signer
Payload QueryPayload
}
func (QueryIssuance) Validate ¶ added in v2026.0.56
func (i QueryIssuance) Validate() error
type QueryPayload ¶ added in v2026.0.56
type QueryPayload struct {
Build core.BuildIdentity `json:"build"`
Query Query `json:"query"`
Nonce controlwire.RequestNonce `json:"request_nonce"`
Revision controlwire.Revision `json:"revision"`
}
QueryPayload is one exact payment catalog query signed by an installed device.
func (QueryPayload) AttestationDomain ¶ added in v2026.0.56
func (QueryPayload) AttestationDomain() SigningDomain
func (QueryPayload) MarshalJSON ¶ added in v2026.0.56
func (p QueryPayload) MarshalJSON() ([]byte, error)
func (*QueryPayload) UnmarshalJSON ¶ added in v2026.0.56
func (p *QueryPayload) UnmarshalJSON(data []byte) error
func (QueryPayload) Validate ¶ added in v2026.0.56
func (p QueryPayload) Validate() error
func (QueryPayload) WriteCanonical ¶ added in v2026.0.56
func (p QueryPayload) WriteCanonical(destination io.Writer) error
type QueryRequest ¶
type QueryRequest struct {
Scope receipt.Scope
Selection Selection
Position Position
PageSize uint16
}
QueryRequest is the constructor boundary for one customer receipt query. PageSize is immediately closed into Core's nominal page limit.
func (QueryRequest) Validate ¶
func (r QueryRequest) Validate() error
Validate closes every constructor input without constructing the query.
type QueryVerification ¶ added in v2026.0.56
type QueryVerification struct {
Document QueryDocument
TrustedKeys attest.TrustedKeys
}
func (QueryVerification) Validate ¶ added in v2026.0.56
func (v QueryVerification) Validate() error
type Selection ¶
type Selection struct {
Payment PaymentID `json:"payment_id"`
Kind core.CatalogSelectionKind `json:"kind"`
}
Selection is the exact all-or-one payment receipt selection.
func (Selection) MarshalJSON ¶
MarshalJSON emits only the member owned by the selected tagged-union arm.
type ServicePeriod ¶
type ServicePeriod struct {
Start temporal.Instant `json:"start"`
End temporal.Instant `json:"end"`
}
ServicePeriod is the exact service interval paid for by one receipt.
func (ServicePeriod) Bounds ¶
func (p ServicePeriod) Bounds() (temporal.IntervalBounds, error)
Bounds returns the validated Temporal-owned interval projection.
func (ServicePeriod) Validate ¶
func (p ServicePeriod) Validate() error
Validate requires two valid, strictly increasing bounds.
type SigningDomain ¶
type SigningDomain uint8
SigningDomain closes the two payment authority statement namespaces.
const ( // SigningDomainUnknown is the invalid zero signing domain. SigningDomainUnknown SigningDomain = iota // SigningDomainReceiptV1 authenticates an immutable payment receipt. SigningDomainReceiptV1 // SigningDomainCatalogV1 authenticates one bounded payment catalog page. SigningDomainCatalogV1 // SigningDomainQueryV1 authenticates one installed device's catalog request. SigningDomainQueryV1 )
func (SigningDomain) IsValid ¶
func (d SigningDomain) IsValid() bool
IsValid reports whether d names one published payment signing namespace.
func (SigningDomain) MarshalJSON ¶
func (d SigningDomain) MarshalJSON() ([]byte, error)
func (SigningDomain) MarshalText ¶
func (d SigningDomain) MarshalText() ([]byte, error)
MarshalText emits the canonical signing token.
func (SigningDomain) ParseCanonicalText ¶
func (SigningDomain) ParseCanonicalText(text []byte) (SigningDomain, error)
ParseCanonicalText accepts one exact payment signing token.
func (SigningDomain) String ¶
func (d SigningDomain) String() string
String returns the canonical token or empty text for an invalid domain.
func (*SigningDomain) UnmarshalJSON ¶
func (d *SigningDomain) UnmarshalJSON(data []byte) error
func (SigningDomain) Validate ¶
func (d SigningDomain) Validate() error
Validate rejects signing domains outside the closed domain.
type Verification ¶
type Verification struct {
Expected Expectation
Document Document
TrustedKeys attest.TrustedKeys
}
Verification carries one untrusted receipt and caller-selected authority keys.
func (Verification) Validate ¶
func (v Verification) Validate() error
Validate closes the complete verification input.
type Verified ¶
type Verified struct {
// contains filtered or unexported fields
}
Verified is the sealed authentication result.
func Verify ¶
func Verify(verification Verification) (Verified, error)
Verify authenticates and binds one exact payment receipt.
type VerifiedQuery ¶ added in v2026.0.56
type VerifiedQuery struct {
// contains filtered or unexported fields
}
func VerifyQuery ¶ added in v2026.0.56
func VerifyQuery(verification QueryVerification) (VerifiedQuery, error)
func (VerifiedQuery) Payload ¶ added in v2026.0.56
func (v VerifiedQuery) Payload() (QueryPayload, error)
func (VerifiedQuery) Validate ¶ added in v2026.0.56
func (v VerifiedQuery) Validate() error