pub struct PaymentErrorDetails {
pub problem_type: String,
pub title: String,
pub status: u16,
pub detail: String,
pub challenge_id: Option<String>,
}Expand description
RFC 9457 Problem Details structure for payment errors.
This struct provides a standardized format for HTTP error responses, following RFC 9457.
§Example
use mpp::error::PaymentErrorDetails;
let problem = PaymentErrorDetails::core("verification-failed")
.with_title("VerificationFailedError")
.with_status(402)
.with_detail("Payment verification failed: insufficient amount.");
// Serialize to JSON for HTTP response body
let json = serde_json::to_string(&problem).unwrap();Fields§
§problem_type: StringA URI reference that identifies the problem type.
title: StringA short, human-readable summary of the problem type.
status: u16The HTTP status code for this problem.
detail: StringA human-readable explanation specific to this occurrence.
challenge_id: Option<String>The challenge ID associated with this error, if applicable.
Implementations§
Source§impl PaymentErrorDetails
impl PaymentErrorDetails
Sourcepub fn new(type_uri: impl Into<String>) -> Self
pub fn new(type_uri: impl Into<String>) -> Self
Create a new PaymentErrorDetails with a full problem type URI.
Sourcepub fn core(suffix: impl Display) -> Self
pub fn core(suffix: impl Display) -> Self
Create a PaymentErrorDetails for a core payment-auth problem.
The full type URI will be {CORE_PROBLEM_TYPE_BASE}/{suffix}.
Sourcepub fn session(suffix: impl Display) -> Self
pub fn session(suffix: impl Display) -> Self
Create a PaymentErrorDetails for a session/channel problem.
The full type URI will be {SESSION_PROBLEM_TYPE_BASE}/{suffix}.
Sourcepub fn stream(suffix: impl Display) -> Self
👎Deprecated since 0.5.0: renamed to session()
pub fn stream(suffix: impl Display) -> Self
renamed to session()
Deprecated: use PaymentErrorDetails::session instead. Remove in next major version.
Sourcepub fn with_title(self, title: impl Into<String>) -> Self
pub fn with_title(self, title: impl Into<String>) -> Self
Set the title.
Sourcepub fn with_status(self, status: u16) -> Self
pub fn with_status(self, status: u16) -> Self
Set the HTTP status code.
Sourcepub fn with_detail(self, detail: impl Into<String>) -> Self
pub fn with_detail(self, detail: impl Into<String>) -> Self
Set the detail message.
Sourcepub fn with_challenge_id(self, id: impl Into<String>) -> Self
pub fn with_challenge_id(self, id: impl Into<String>) -> Self
Set the associated challenge ID.
Trait Implementations§
Source§impl Clone for PaymentErrorDetails
impl Clone for PaymentErrorDetails
Source§fn clone(&self) -> PaymentErrorDetails
fn clone(&self) -> PaymentErrorDetails
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more