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
use serde_derive::{Deserialize, Serialize};
use crate::resources::{BankAccount, Card, PaymentIntent, PaymentMethod, SetupIntent, Source};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct ApiErrors {
#[serde(skip_serializing_if = "Option::is_none")]
pub charge: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub code: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub decline_code: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub doc_url: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub message: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub param: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_intent: Option<Box<PaymentIntent>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method: Option<Box<PaymentMethod>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub payment_method_type: Option<Box<String>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub setup_intent: Option<Box<SetupIntent>>,
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<Box<ApiErrorsSourceUnion>>,
#[serde(rename = "type")]
pub type_: ApiErrorsType,
}
#[derive(Clone, Debug, Deserialize, Serialize)]
#[serde(tag = "object", rename_all = "snake_case")]
pub enum ApiErrorsSourceUnion {
BankAccount(BankAccount),
Card(Card),
Source(Source),
}
#[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)
}
}