pub struct PaymentRequirements {
pub scheme: String,
pub network: String,
pub max_amount_required: String,
pub asset: String,
pub pay_to: String,
pub resource: String,
pub description: String,
pub mime_type: Option<String>,
pub output_schema: Option<Value>,
pub max_timeout_seconds: u32,
pub extra: Option<Value>,
}Expand description
Payment requirements for a resource
Fields§
§scheme: StringPayment scheme identifier (e.g., “exact”)
network: StringBlockchain network identifier (e.g., “base-sepolia”, “ethereum-mainnet”)
max_amount_required: StringRequired payment amount in atomic token units
asset: StringToken contract address
pay_to: StringRecipient wallet address for the payment
resource: StringURL of the protected resource
description: StringHuman-readable description of the resource
mime_type: Option<String>MIME type of the expected response
output_schema: Option<Value>JSON schema describing the response format
max_timeout_seconds: u32Maximum time allowed for payment completion in seconds
extra: Option<Value>Scheme-specific additional information
Implementations§
Source§impl PaymentRequirements
impl PaymentRequirements
Sourcepub fn new(
scheme: impl Into<String>,
network: impl Into<String>,
max_amount_required: impl Into<String>,
asset: impl Into<String>,
pay_to: impl Into<String>,
resource: impl Into<String>,
description: impl Into<String>,
) -> Self
pub fn new( scheme: impl Into<String>, network: impl Into<String>, max_amount_required: impl Into<String>, asset: impl Into<String>, pay_to: impl Into<String>, resource: impl Into<String>, description: impl Into<String>, ) -> Self
Create a new payment requirements instance
Sourcepub fn set_usdc_info(&mut self, network: Network) -> Result<()>
pub fn set_usdc_info(&mut self, network: Network) -> Result<()>
Set USDC token information in the extra field
Sourcepub fn amount_as_decimal(&self) -> Result<Decimal>
pub fn amount_as_decimal(&self) -> Result<Decimal>
Get the amount as a decimal
Sourcepub fn amount_in_decimal_units(&self, decimals: u8) -> Result<Decimal>
pub fn amount_in_decimal_units(&self, decimals: u8) -> Result<Decimal>
Get the amount in decimal units (e.g., 0.01 for 1 cent)
Trait Implementations§
Source§impl Clone for PaymentRequirements
impl Clone for PaymentRequirements
Source§fn clone(&self) -> PaymentRequirements
fn clone(&self) -> PaymentRequirements
Returns a duplicate of the value. Read more
1.0.0 · 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 PaymentRequirements
impl Debug for PaymentRequirements
Source§impl<'de> Deserialize<'de> for PaymentRequirements
impl<'de> Deserialize<'de> for PaymentRequirements
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for PaymentRequirements
impl RefUnwindSafe for PaymentRequirements
impl Send for PaymentRequirements
impl Sync for PaymentRequirements
impl Unpin for PaymentRequirements
impl UnwindSafe for PaymentRequirements
Blanket Implementations§
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