#[non_exhaustive]pub struct PaymentPayload<TAccepted, TPayload> {
pub accepted: TAccepted,
pub payload: TPayload,
pub resource: Option<ResourceInfo>,
pub x402_version: Version2,
pub extensions: Extensions,
}Expand description
A signed payment authorization sent by the buyer to the seller.
In x402 v2 the payload is self-describing: it carries the accepted
requirements the buyer chose (so the facilitator can re-verify them)
plus the scheme-specific payload, an optional resource descriptor,
and an optional extensions map.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.accepted: TAcceptedThe terms the buyer accepted (a full super::PaymentRequirements form).
payload: TPayloadScheme-specific signed payload (e.g., EIP-3009 authorization).
resource: Option<ResourceInfo>Optional resource metadata copied from the 402 response.
x402_version: Version2Protocol version marker (always 2).
extensions: ExtensionsOptional extension payload block.
Implementations§
Source§impl<TAccepted, TPayload> PaymentPayload<TAccepted, TPayload>
impl<TAccepted, TPayload> PaymentPayload<TAccepted, TPayload>
Sourcepub fn new(accepted: TAccepted, payload: TPayload) -> Self
pub fn new(accepted: TAccepted, payload: TPayload) -> Self
Constructs a payload from the two required fields. Use the
Self::with_resource / Self::with_extensions builders to
attach the optional blocks.
Sourcepub fn with_resource(self, resource: ResourceInfo) -> Self
pub fn with_resource(self, resource: ResourceInfo) -> Self
Builder: attaches optional resource metadata.
Sourcepub fn with_optional_resource(self, resource: Option<ResourceInfo>) -> Self
pub fn with_optional_resource(self, resource: Option<ResourceInfo>) -> Self
Builder: attaches an optional resource (passes through None
untouched, useful when the value is produced via Option::map).
Sourcepub fn with_extensions(self, extensions: Extensions) -> Self
pub fn with_extensions(self, extensions: Extensions) -> Self
Builder: replaces the extensions block.
Trait Implementations§
Source§impl<TAccepted: Clone, TPayload: Clone> Clone for PaymentPayload<TAccepted, TPayload>
impl<TAccepted: Clone, TPayload: Clone> Clone for PaymentPayload<TAccepted, TPayload>
Source§fn clone(&self) -> PaymentPayload<TAccepted, TPayload>
fn clone(&self) -> PaymentPayload<TAccepted, TPayload>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more