pub struct PaymentMiddleware {
pub config: Arc<PaymentMiddlewareConfig>,
pub facilitator: Option<FacilitatorClient>,
pub template_config: Option<PaywallConfig>,
}Expand description
Axum middleware for x402 payments
Fields§
§config: Arc<PaymentMiddlewareConfig>§facilitator: Option<FacilitatorClient>§template_config: Option<PaywallConfig>Implementations§
Source§impl PaymentMiddleware
impl PaymentMiddleware
Sourcepub fn with_description(self, description: impl Into<String>) -> Self
pub fn with_description(self, description: impl Into<String>) -> Self
Set the payment description
Sourcepub fn with_mime_type(self, mime_type: impl Into<String>) -> Self
pub fn with_mime_type(self, mime_type: impl Into<String>) -> Self
Set the MIME type
Sourcepub fn with_max_timeout_seconds(self, max_timeout_seconds: u32) -> Self
pub fn with_max_timeout_seconds(self, max_timeout_seconds: u32) -> Self
Set the maximum timeout
Sourcepub fn with_output_schema(self, output_schema: Value) -> Self
pub fn with_output_schema(self, output_schema: Value) -> Self
Set the output schema
Sourcepub fn with_facilitator_config(
self,
facilitator_config: FacilitatorConfig,
) -> Self
pub fn with_facilitator_config( self, facilitator_config: FacilitatorConfig, ) -> Self
Set the facilitator configuration
Sourcepub fn with_testnet(self, testnet: bool) -> Self
pub fn with_testnet(self, testnet: bool) -> Self
Set whether this is a testnet
Sourcepub fn with_custom_paywall_html(self, html: impl Into<String>) -> Self
pub fn with_custom_paywall_html(self, html: impl Into<String>) -> Self
Set custom paywall HTML
Sourcepub fn with_resource(self, resource: impl Into<String>) -> Self
pub fn with_resource(self, resource: impl Into<String>) -> Self
Set the resource URL
Sourcepub fn with_resource_root_url(self, url: impl Into<String>) -> Self
pub fn with_resource_root_url(self, url: impl Into<String>) -> Self
Set the resource root URL
Sourcepub fn config(&self) -> &PaymentMiddlewareConfig
pub fn config(&self) -> &PaymentMiddlewareConfig
Get the middleware configuration
Sourcepub fn with_facilitator(self, facilitator: FacilitatorClient) -> Self
pub fn with_facilitator(self, facilitator: FacilitatorClient) -> Self
Set the facilitator client
Sourcepub fn with_template_config(self, template_config: PaywallConfig) -> Self
pub fn with_template_config(self, template_config: PaywallConfig) -> Self
Set the template configuration
Sourcepub async fn verify(&self, payment_payload: &PaymentPayload) -> bool
pub async fn verify(&self, payment_payload: &PaymentPayload) -> bool
Verify a payment payload
Sourcepub async fn settle(
&self,
payment_payload: &PaymentPayload,
) -> Result<SettleResponse>
pub async fn settle( &self, payment_payload: &PaymentPayload, ) -> Result<SettleResponse>
Settle a payment
Sourcepub async fn verify_with_requirements(
&self,
payment_payload: &PaymentPayload,
requirements: &PaymentRequirements,
) -> Result<bool>
pub async fn verify_with_requirements( &self, payment_payload: &PaymentPayload, requirements: &PaymentRequirements, ) -> Result<bool>
Verify payment with specific requirements
Sourcepub async fn settle_with_requirements(
&self,
payment_payload: &PaymentPayload,
requirements: &PaymentRequirements,
) -> Result<SettleResponse>
pub async fn settle_with_requirements( &self, payment_payload: &PaymentPayload, requirements: &PaymentRequirements, ) -> Result<SettleResponse>
Settle payment with specific requirements
Sourcepub async fn process_payment(
&self,
request: Request,
next: Next,
) -> Result<PaymentResult>
pub async fn process_payment( &self, request: Request, next: Next, ) -> Result<PaymentResult>
Process payment with unified flow
Trait Implementations§
Source§impl Clone for PaymentMiddleware
impl Clone for PaymentMiddleware
Source§fn clone(&self) -> PaymentMiddleware
fn clone(&self) -> PaymentMiddleware
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 moreAuto Trait Implementations§
impl Freeze for PaymentMiddleware
impl !RefUnwindSafe for PaymentMiddleware
impl Send for PaymentMiddleware
impl Sync for PaymentMiddleware
impl Unpin for PaymentMiddleware
impl !UnwindSafe for PaymentMiddleware
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