pub struct PaymentRequest {
pub max_amount_required: String,
pub asset_type: String,
pub asset_address: String,
pub payment_address: String,
pub network: String,
pub expires_at: DateTime<Utc>,
pub nonce: String,
pub payment_id: String,
pub resource: String,
pub description: Option<String>,
}Expand description
Payment request received from server in 402 response
Fields§
§max_amount_required: StringMaximum amount required in USDC (e.g., “0.10”)
asset_type: StringType of asset (e.g., “SPL” for Solana Program Library tokens)
asset_address: StringToken mint address (USDC address on Solana)
payment_address: StringRecipient wallet address for payment
network: StringNetwork identifier (e.g., “solana-devnet”, “solana-mainnet”)
expires_at: DateTime<Utc>Expiration timestamp (ISO 8601 format)
nonce: StringNonce for replay protection
payment_id: StringUnique payment identifier
resource: StringAPI endpoint/resource being accessed
description: Option<String>Human-readable description (optional)
Implementations§
Source§impl PaymentRequest
impl PaymentRequest
Sourcepub fn new(
max_amount_required: String,
asset_address: String,
payment_address: String,
network: String,
expires_at: DateTime<Utc>,
nonce: String,
payment_id: String,
resource: String,
) -> PaymentRequest
pub fn new( max_amount_required: String, asset_address: String, payment_address: String, network: String, expires_at: DateTime<Utc>, nonce: String, payment_id: String, resource: String, ) -> PaymentRequest
Create a new payment request
Sourcepub fn with_description(self, description: String) -> PaymentRequest
pub fn with_description(self, description: String) -> PaymentRequest
Set the description
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the payment request has expired
Sourcepub fn from_json(json: &str) -> Result<PaymentRequest, X402Error>
pub fn from_json(json: &str) -> Result<PaymentRequest, X402Error>
Parse payment request from JSON string
Sourcepub fn from_base64(encoded: &str) -> Result<PaymentRequest, X402Error>
pub fn from_base64(encoded: &str) -> Result<PaymentRequest, X402Error>
Decode payment request from base64 JSON
Trait Implementations§
Source§impl Clone for PaymentRequest
impl Clone for PaymentRequest
Source§fn clone(&self) -> PaymentRequest
fn clone(&self) -> PaymentRequest
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PaymentRequest
impl Debug for PaymentRequest
Source§impl<'de> Deserialize<'de> for PaymentRequest
impl<'de> Deserialize<'de> for PaymentRequest
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<PaymentRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<PaymentRequest, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl PartialEq for PaymentRequest
impl PartialEq for PaymentRequest
Source§impl Serialize for PaymentRequest
impl Serialize for PaymentRequest
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for PaymentRequest
Auto Trait Implementations§
impl Freeze for PaymentRequest
impl RefUnwindSafe for PaymentRequest
impl Send for PaymentRequest
impl Sync for PaymentRequest
impl Unpin for PaymentRequest
impl UnsafeUnpin for PaymentRequest
impl UnwindSafe for PaymentRequest
Blanket Implementations§
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more