stripe/resources/generated/card.rs
1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::ids::CardId;
6use crate::params::{Expandable, Metadata, Object};
7use crate::resources::{Account, Currency, Customer};
8use serde::{Deserialize, Serialize};
9
10/// The resource representing a Stripe "Card".
11///
12/// For more details see <https://stripe.com/docs/api/cards/object>
13#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct Card {
15 /// Unique identifier for the object.
16 pub id: CardId,
17
18 /// The account this card belongs to.
19 ///
20 /// This attribute will not be in the card object if the card belongs to a customer or recipient instead.
21 #[serde(skip_serializing_if = "Option::is_none")]
22 pub account: Option<Expandable<Account>>,
23
24 /// City/District/Suburb/Town/Village.
25 #[serde(skip_serializing_if = "Option::is_none")]
26 pub address_city: Option<String>,
27
28 /// Billing address country, if provided when creating card.
29 #[serde(skip_serializing_if = "Option::is_none")]
30 pub address_country: Option<String>,
31
32 /// Address line 1 (Street address/PO Box/Company name).
33 #[serde(skip_serializing_if = "Option::is_none")]
34 pub address_line1: Option<String>,
35
36 /// If `address_line1` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
37 #[serde(skip_serializing_if = "Option::is_none")]
38 pub address_line1_check: Option<String>,
39
40 /// Address line 2 (Apartment/Suite/Unit/Building).
41 #[serde(skip_serializing_if = "Option::is_none")]
42 pub address_line2: Option<String>,
43
44 /// State/County/Province/Region.
45 #[serde(skip_serializing_if = "Option::is_none")]
46 pub address_state: Option<String>,
47
48 /// ZIP or postal code.
49 #[serde(skip_serializing_if = "Option::is_none")]
50 pub address_zip: Option<String>,
51
52 /// If `address_zip` was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
53 #[serde(skip_serializing_if = "Option::is_none")]
54 pub address_zip_check: Option<String>,
55
56 /// A set of available payout methods for this card.
57 ///
58 /// Only values from this set should be passed as the `method` when creating a payout.
59 #[serde(skip_serializing_if = "Option::is_none")]
60 pub available_payout_methods: Option<Vec<CardAvailablePayoutMethods>>,
61
62 /// Card brand.
63 ///
64 /// Can be `American Express`, `Diners Club`, `Discover`, `Eftpos Australia`, `JCB`, `MasterCard`, `UnionPay`, `Visa`, or `Unknown`.
65 #[serde(skip_serializing_if = "Option::is_none")]
66 pub brand: Option<String>,
67
68 /// Two-letter ISO code representing the country of the card.
69 ///
70 /// You could use this attribute to get a sense of the international breakdown of cards you've collected.
71 #[serde(skip_serializing_if = "Option::is_none")]
72 pub country: Option<String>,
73
74 /// Three-letter [ISO code for currency](https://stripe.com/docs/payouts).
75 ///
76 /// Only applicable on accounts (not customers or recipients).
77 /// The card can be used as a transfer destination for funds in this currency.
78 #[serde(skip_serializing_if = "Option::is_none")]
79 pub currency: Option<Currency>,
80
81 /// The customer that this card belongs to.
82 ///
83 /// This attribute will not be in the card object if the card belongs to an account or recipient instead.
84 #[serde(skip_serializing_if = "Option::is_none")]
85 pub customer: Option<Expandable<Customer>>,
86
87 /// If a CVC was provided, results of the check: `pass`, `fail`, `unavailable`, or `unchecked`.
88 ///
89 /// A result of unchecked indicates that CVC was provided but hasn't been checked yet.
90 /// Checks are typically performed when attaching a card to a Customer object, or when creating a charge.
91 /// For more details, see [Check if a card is valid without a charge](https://support.stripe.com/questions/check-if-a-card-is-valid-without-a-charge).
92 #[serde(skip_serializing_if = "Option::is_none")]
93 pub cvc_check: Option<String>,
94
95 /// Whether this card is the default external account for its currency.
96 #[serde(skip_serializing_if = "Option::is_none")]
97 pub default_for_currency: Option<bool>,
98
99 // Always true for a deleted object
100 #[serde(default)]
101 pub deleted: bool,
102
103 /// A high-level description of the type of cards issued in this range.
104 ///
105 /// (For internal use only and not typically available in standard API requests.).
106 #[serde(skip_serializing_if = "Option::is_none")]
107 pub description: Option<String>,
108
109 /// (For tokenized numbers only.) The last four digits of the device account number.
110 #[serde(skip_serializing_if = "Option::is_none")]
111 pub dynamic_last4: Option<String>,
112
113 /// Two-digit number representing the card's expiration month.
114 #[serde(skip_serializing_if = "Option::is_none")]
115 pub exp_month: Option<i64>,
116
117 /// Four-digit number representing the card's expiration year.
118 #[serde(skip_serializing_if = "Option::is_none")]
119 pub exp_year: Option<i64>,
120
121 /// Uniquely identifies this particular card number.
122 ///
123 /// You can use this attribute to check whether two customers who’ve signed up with you are using the same card number, for example.
124 /// For payment methods that tokenize card information (Apple Pay, Google Pay), the tokenized number might be provided instead of the underlying card number. *As of May 1, 2021, card fingerprint in India for Connect changed to allow two fingerprints for the same card---one for India and one for the rest of the world.*.
125 #[serde(skip_serializing_if = "Option::is_none")]
126 pub fingerprint: Option<String>,
127
128 /// Card funding type.
129 ///
130 /// Can be `credit`, `debit`, `prepaid`, or `unknown`.
131 #[serde(skip_serializing_if = "Option::is_none")]
132 pub funding: Option<String>,
133
134 /// Issuer identification number of the card.
135 ///
136 /// (For internal use only and not typically available in standard API requests.).
137 #[serde(skip_serializing_if = "Option::is_none")]
138 pub iin: Option<String>,
139
140 /// The name of the card's issuing bank.
141 ///
142 /// (For internal use only and not typically available in standard API requests.).
143 #[serde(skip_serializing_if = "Option::is_none")]
144 pub issuer: Option<String>,
145
146 /// The last four digits of the card.
147 #[serde(skip_serializing_if = "Option::is_none")]
148 pub last4: Option<String>,
149
150 /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
151 ///
152 /// This can be useful for storing additional information about the object in a structured format.
153 #[serde(skip_serializing_if = "Option::is_none")]
154 pub metadata: Option<Metadata>,
155
156 /// Cardholder name.
157 #[serde(skip_serializing_if = "Option::is_none")]
158 pub name: Option<String>,
159
160 /// For external accounts that are cards, possible values are `new` and `errored`.
161 ///
162 /// If a payout fails, the status is set to `errored` and [scheduled payouts](https://stripe.com/docs/payouts#payout-schedule) are stopped until account details are updated.
163 #[serde(skip_serializing_if = "Option::is_none")]
164 pub status: Option<String>,
165
166 /// If the card number is tokenized, this is the method that was used.
167 ///
168 /// Can be `android_pay` (includes Google Pay), `apple_pay`, `masterpass`, `visa_checkout`, or null.
169 #[serde(skip_serializing_if = "Option::is_none")]
170 pub tokenization_method: Option<String>,
171}
172
173impl Object for Card {
174 type Id = CardId;
175 fn id(&self) -> Self::Id {
176 self.id.clone()
177 }
178 fn object(&self) -> &'static str {
179 "card"
180 }
181}
182
183/// An enum representing the possible values of an `Card`'s `available_payout_methods` field.
184#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
185#[serde(rename_all = "snake_case")]
186pub enum CardAvailablePayoutMethods {
187 Instant,
188 Standard,
189}
190
191impl CardAvailablePayoutMethods {
192 pub fn as_str(self) -> &'static str {
193 match self {
194 CardAvailablePayoutMethods::Instant => "instant",
195 CardAvailablePayoutMethods::Standard => "standard",
196 }
197 }
198}
199
200impl AsRef<str> for CardAvailablePayoutMethods {
201 fn as_ref(&self) -> &str {
202 self.as_str()
203 }
204}
205
206impl std::fmt::Display for CardAvailablePayoutMethods {
207 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
208 self.as_str().fmt(f)
209 }
210}
211impl std::default::Default for CardAvailablePayoutMethods {
212 fn default() -> Self {
213 Self::Instant
214 }
215}