Documentation
¶
Index ¶
- func DetectVersion(data []byte) (int, error)
- func GetSchemeAndNetwork(version int, payloadBytes []byte) (scheme string, network string, err error)
- func MatchPayloadToRequirements(version int, payloadBytes []byte, requirementsBytes []byte) (bool, error)
- type PayloadBase
- type PaymentPayload
- type PaymentPayloadV1
- type PaymentRequired
- type PaymentRequiredPartial
- type PaymentRequiredV1
- type PaymentRequirements
- func (r PaymentRequirements) GetAmount() string
- func (r PaymentRequirements) GetAsset() string
- func (r PaymentRequirements) GetExtra() map[string]interface{}
- func (r PaymentRequirements) GetMaxTimeoutSeconds() int
- func (r PaymentRequirements) GetNetwork() string
- func (r PaymentRequirements) GetPayTo() string
- func (r PaymentRequirements) GetScheme() string
- type PaymentRequirementsV1
- func (r PaymentRequirementsV1) GetAmount() string
- func (r PaymentRequirementsV1) GetAsset() string
- func (r PaymentRequirementsV1) GetExtra() map[string]interface{}
- func (r PaymentRequirementsV1) GetMaxTimeoutSeconds() int
- func (r PaymentRequirementsV1) GetNetwork() string
- func (r PaymentRequirementsV1) GetPayTo() string
- func (r PaymentRequirementsV1) GetScheme() string
- type RequirementsInfo
- type ResourceInfo
- type ResourceServerExtension
- type SupportedKind
- type SupportedKindV1
- type SupportedResponse
- type SupportedResponseV1
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DetectVersion ¶
DetectVersion extracts x402Version from JSON bytes
func GetSchemeAndNetwork ¶
func GetSchemeAndNetwork(version int, payloadBytes []byte) (scheme string, network string, err error)
GetSchemeAndNetwork extracts scheme and network from payment payload bytes This is one of TWO version-aware functions in core (co-located for maintainability) Used by facilitator for routing
func MatchPayloadToRequirements ¶
func MatchPayloadToRequirements( version int, payloadBytes []byte, requirementsBytes []byte, ) (bool, error)
MatchPayloadToRequirements checks if payment payload matches requirements This is one of TWO version-aware functions in core (co-located for maintainability) Used by server.FindMatchingRequirements
Types ¶
type PayloadBase ¶
type PayloadBase struct {
X402Version int `json:"x402Version"`
Payload map[string]interface{} `json:"payload"`
}
PayloadBase is minimal payload structure (version + payload field only) Used by v2 client to return partial payload before core wraps it
func ToPayloadBase ¶
func ToPayloadBase(data []byte) (*PayloadBase, error)
ToPayloadBase unmarshals just version and payload field
type PaymentPayload ¶
type PaymentPayload struct {
X402Version int `json:"x402Version"`
Payload map[string]interface{} `json:"payload"`
Accepted PaymentRequirements `json:"accepted"`
Resource *ResourceInfo `json:"resource,omitempty"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
}
PaymentPayload represents a v2 payment payload structure V2 has accepted field with nested scheme/network/requirements
func ToPaymentPayload ¶
func ToPaymentPayload(data []byte) (*PaymentPayload, error)
ToPaymentPayload unmarshals bytes to v2 payment payload
func (PaymentPayload) GetNetwork ¶
func (p PaymentPayload) GetNetwork() string
func (PaymentPayload) GetPayload ¶
func (p PaymentPayload) GetPayload() map[string]interface{}
func (PaymentPayload) GetScheme ¶
func (p PaymentPayload) GetScheme() string
func (PaymentPayload) GetVersion ¶
func (p PaymentPayload) GetVersion() int
PaymentPayloadView interface implementation for V2
type PaymentPayloadV1 ¶
type PaymentPayloadV1 struct {
X402Version int `json:"x402Version"`
Scheme string `json:"scheme"`
Network string `json:"network"`
Payload map[string]interface{} `json:"payload"`
}
PaymentPayloadV1 represents a v1 payment payload structure V1 has scheme and network at top level (not in accepted field)
func ToPaymentPayloadV1 ¶
func ToPaymentPayloadV1(data []byte) (*PaymentPayloadV1, error)
ToPaymentPayloadV1 unmarshals bytes to v1 payment payload
func (PaymentPayloadV1) GetNetwork ¶
func (p PaymentPayloadV1) GetNetwork() string
func (PaymentPayloadV1) GetPayload ¶
func (p PaymentPayloadV1) GetPayload() map[string]interface{}
func (PaymentPayloadV1) GetScheme ¶
func (p PaymentPayloadV1) GetScheme() string
func (PaymentPayloadV1) GetVersion ¶
func (p PaymentPayloadV1) GetVersion() int
PaymentPayloadView interface implementation for V1
type PaymentRequired ¶
type PaymentRequired struct {
X402Version int `json:"x402Version"`
Error string `json:"error,omitempty"`
Resource *ResourceInfo `json:"resource,omitempty"`
Accepts []PaymentRequirements `json:"accepts"`
Extensions map[string]interface{} `json:"extensions,omitempty"`
}
PaymentRequired represents a v2 402 response structure
func ToPaymentRequired ¶
func ToPaymentRequired(data []byte) (*PaymentRequired, error)
ToPaymentRequired unmarshals bytes to v2 payment required response
type PaymentRequiredPartial ¶
type PaymentRequiredPartial struct {
X402Version int `json:"x402Version"`
Error string `json:"error,omitempty"`
Accepts []json.RawMessage `json:"accepts"` // Keep as raw bytes
Resource json.RawMessage `json:"resource,omitempty"`
Extensions json.RawMessage `json:"extensions,omitempty"`
}
PaymentRequiredPartial for extracting accepts array as raw bytes Keeps accepts as raw bytes to avoid version-specific unmarshaling
func ToPaymentRequiredPartial ¶
func ToPaymentRequiredPartial(data []byte) (*PaymentRequiredPartial, error)
ToPaymentRequiredPartial unmarshals PaymentRequired keeping accepts as raw bytes
type PaymentRequiredV1 ¶
type PaymentRequiredV1 struct {
X402Version int `json:"x402Version"`
Error string `json:"error,omitempty"`
Accepts []PaymentRequirementsV1 `json:"accepts"`
}
PaymentRequiredV1 represents a v1 402 response structure
func ToPaymentRequiredV1 ¶
func ToPaymentRequiredV1(data []byte) (*PaymentRequiredV1, error)
ToPaymentRequiredV1 unmarshals bytes to v1 payment required response
type PaymentRequirements ¶
type PaymentRequirements struct {
Scheme string `json:"scheme"`
Network string `json:"network"`
Asset string `json:"asset"`
Amount string `json:"amount"`
PayTo string `json:"payTo"`
MaxTimeoutSeconds int `json:"maxTimeoutSeconds"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
PaymentRequirements represents v2 payment requirements structure
func ToPaymentRequirements ¶
func ToPaymentRequirements(data []byte) (*PaymentRequirements, error)
ToPaymentRequirements unmarshals bytes to v2 payment requirements
func (PaymentRequirements) GetAmount ¶
func (r PaymentRequirements) GetAmount() string
func (PaymentRequirements) GetAsset ¶
func (r PaymentRequirements) GetAsset() string
func (PaymentRequirements) GetExtra ¶
func (r PaymentRequirements) GetExtra() map[string]interface{}
func (PaymentRequirements) GetMaxTimeoutSeconds ¶
func (r PaymentRequirements) GetMaxTimeoutSeconds() int
func (PaymentRequirements) GetNetwork ¶
func (r PaymentRequirements) GetNetwork() string
func (PaymentRequirements) GetPayTo ¶
func (r PaymentRequirements) GetPayTo() string
func (PaymentRequirements) GetScheme ¶
func (r PaymentRequirements) GetScheme() string
PaymentRequirementsView interface implementation for V2
type PaymentRequirementsV1 ¶
type PaymentRequirementsV1 struct {
Scheme string `json:"scheme"`
Network string `json:"network"`
MaxAmountRequired string `json:"maxAmountRequired"`
Resource string `json:"resource"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
PayTo string `json:"payTo"`
MaxTimeoutSeconds int `json:"maxTimeoutSeconds"`
Asset string `json:"asset"`
OutputSchema *json.RawMessage `json:"outputSchema,omitempty"`
Extra *json.RawMessage `json:"extra,omitempty"`
}
PaymentRequirementsV1 represents v1 payment requirements structure
func ToPaymentRequirementsV1 ¶
func ToPaymentRequirementsV1(data []byte) (*PaymentRequirementsV1, error)
ToPaymentRequirementsV1 unmarshals bytes to v1 payment requirements
func (PaymentRequirementsV1) GetAmount ¶
func (r PaymentRequirementsV1) GetAmount() string
func (PaymentRequirementsV1) GetAsset ¶
func (r PaymentRequirementsV1) GetAsset() string
func (PaymentRequirementsV1) GetExtra ¶
func (r PaymentRequirementsV1) GetExtra() map[string]interface{}
func (PaymentRequirementsV1) GetMaxTimeoutSeconds ¶
func (r PaymentRequirementsV1) GetMaxTimeoutSeconds() int
func (PaymentRequirementsV1) GetNetwork ¶
func (r PaymentRequirementsV1) GetNetwork() string
func (PaymentRequirementsV1) GetPayTo ¶
func (r PaymentRequirementsV1) GetPayTo() string
func (PaymentRequirementsV1) GetScheme ¶
func (r PaymentRequirementsV1) GetScheme() string
PaymentRequirementsView interface implementation for V1
type RequirementsInfo ¶
RequirementsInfo is minimal info extracted from requirements for routing
func ExtractRequirementsInfo ¶
func ExtractRequirementsInfo(data []byte) (*RequirementsInfo, error)
ExtractRequirementsInfo gets scheme and network from requirements bytes Works for both v1 and v2 (both have scheme/network at top level)
type ResourceInfo ¶
type ResourceInfo struct {
URL string `json:"url"`
Description string `json:"description,omitempty"`
MimeType string `json:"mimeType,omitempty"`
}
ResourceInfo describes the resource being accessed
type ResourceServerExtension ¶
type ResourceServerExtension interface {
Key() string
EnrichDeclaration(declaration interface{}, transportContext interface{}) interface{}
}
type SupportedKind ¶
type SupportedKind struct {
X402Version int `json:"x402Version"`
Scheme string `json:"scheme"`
Network string `json:"network"`
Extra map[string]interface{} `json:"extra,omitempty"`
}
SupportedKind represents a supported payment configuration
func ToSupportedKind ¶
func ToSupportedKind(data []byte) (*SupportedKind, error)
ToSupportedKind unmarshals bytes to v2 supported kind
type SupportedKindV1 ¶
type SupportedKindV1 struct {
X402Version int `json:"x402Version"`
Scheme string `json:"scheme"`
Network string `json:"network"`
Extra *json.RawMessage `json:"extra,omitempty"`
}
SupportedKindV1 represents a V1 supported payment configuration
func ToSupportedKindV1 ¶
func ToSupportedKindV1(data []byte) (*SupportedKindV1, error)
ToSupportedKindV1 unmarshals bytes to v1 supported kind
type SupportedResponse ¶
type SupportedResponse struct {
Kinds []SupportedKind `json:"kinds"` // Array of kinds with version in each element
Extensions []string `json:"extensions"` // Protocol extensions supported
Signers map[string][]string `json:"signers"` // CAIP family → Signer addresses
}
SupportedResponse describes what payment kinds a facilitator supports
type SupportedResponseV1 ¶
type SupportedResponseV1 struct {
Kinds []SupportedKindV1 `json:"kinds"`
}
SupportedResponseV1 is the old supported response format (V1 only, no extensions)