1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105
// ======================================
// This file was automatically generated.
// ======================================
use serde::{Deserialize, Serialize};
use crate::resources::{PaymentIntent, PaymentMethod, PaymentSource, SetupIntent};
/// The resource representing a Stripe "APIErrors".
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct ApiErrors {
/// For card errors, the ID of the failed charge.
#[serde(skip_serializing_if = "Option::is_none")]
pub charge: Option<String>,
/// For some errors that could be handled programmatically, a short string indicating the [error code](https://stripe.com/docs/error-codes) reported.
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option<String>,
/// For card errors resulting from a card issuer decline, a short string indicating the [card issuer's reason for the decline](https://stripe.com/docs/declines#issuer-declines) if they provide one.
#[serde(skip_serializing_if = "Option::is_none")]
pub decline_code: Option<String>,
/// A URL to more information about the [error code](https://stripe.com/docs/error-codes) reported.
#[serde(skip_serializing_if = "Option::is_none")]
pub doc_url: Option<String>,
/// A human-readable message providing more details about the error.
///
/// For card errors, these messages can be shown to your users.
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<String>,
/// If the error is parameter-specific, the parameter related to the error.
///
/// For example, you can use this to display a message near the correct form field.
#[serde(skip_serializing_if = "Option::is_none")]
pub param: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_intent: Option<PaymentIntent>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method: Option<PaymentMethod>,
/// If the error is specific to the type of payment method, the payment method type that had a problem.
///
/// This field is only populated for invoice-related errors.
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method_type: Option<String>,
/// A URL to the request log entry in your dashboard.
#[serde(skip_serializing_if = "Option::is_none")]
pub request_log_url: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub setup_intent: Option<SetupIntent>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<PaymentSource>,
/// The type of error returned.
///
/// One of `api_error`, `card_error`, `idempotency_error`, or `invalid_request_error`.
#[serde(rename = "type")]
pub type_: ApiErrorsType,
}
/// An enum representing the possible values of an `ApiErrors`'s `type` field.
#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
#[serde(rename_all = "snake_case")]
pub enum ApiErrorsType {
ApiError,
CardError,
IdempotencyError,
InvalidRequestError,
}
impl ApiErrorsType {
pub fn as_str(self) -> &'static str {
match self {
ApiErrorsType::ApiError => "api_error",
ApiErrorsType::CardError => "card_error",
ApiErrorsType::IdempotencyError => "idempotency_error",
ApiErrorsType::InvalidRequestError => "invalid_request_error",
}
}
}
impl AsRef<str> for ApiErrorsType {
fn as_ref(&self) -> &str {
self.as_str()
}
}
impl std::fmt::Display for ApiErrorsType {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
self.as_str().fmt(f)
}
}
impl std::default::Default for ApiErrorsType {
fn default() -> Self {
Self::ApiError
}
}