pub struct PaymentState {
pub verified: Option<VerifyValid>,
pub settled: Option<SettleSuccess>,
pub required_extensions: HashMap<String, Extension>,
pub payload_extensions: HashMap<String, Extension>,
}Expand description
The state of a payment processed by the paywall when accessing the resource handler.
This state is attached to the request extensions before running the resource handler, and can be accessed within the handler to inspect the payment status.
§Example
use axum::{extract::Extension, Json};
use serde_json::{json, Value};
use x402_core::facilitator::{VerifyValid, SettleSuccess};
use x402_paywall::processor::PaymentState;
async fn example_handler(Extension(payment_state): Extension<PaymentState>) -> Json<Value> {
Json(json!({
"message": "You have accessed a protected resource!",
"verify_state": serde_json::to_value(&payment_state.verified).unwrap_or(json!(null)),
"settle_state": serde_json::to_value(&payment_state.settled).unwrap_or(json!(null)),
}))
}Fields§
§verified: Option<VerifyValid>Verification result, if verification was performed.
settled: Option<SettleSuccess>Settlement result, if settlement was performed.
required_extensions: HashMap<String, Extension>All extensions info provided by the paywall.
payload_extensions: HashMap<String, Extension>All extensions info provided by the signer.
Trait Implementations§
Source§impl Clone for PaymentState
impl Clone for PaymentState
Source§fn clone(&self) -> PaymentState
fn clone(&self) -> PaymentState
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 PaymentState
impl RefUnwindSafe for PaymentState
impl Send for PaymentState
impl Sync for PaymentState
impl Unpin for PaymentState
impl UnwindSafe for PaymentState
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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