stripe/resources/generated/
issuing_token.rs

1// ======================================
2// This file was automatically generated.
3// ======================================
4
5use crate::ids::IssuingTokenId;
6use crate::params::{Expandable, Object, Timestamp};
7use crate::resources::IssuingCard;
8use serde::{Deserialize, Serialize};
9
10/// The resource representing a Stripe "IssuingNetworkToken".
11///
12/// For more details see <https://stripe.com/docs/api/issuing/tokens/object>
13#[derive(Clone, Debug, Default, Deserialize, Serialize)]
14pub struct IssuingToken {
15    /// Unique identifier for the object.
16    pub id: IssuingTokenId,
17
18    /// Card associated with this token.
19    pub card: Expandable<IssuingCard>,
20
21    /// Time at which the object was created.
22    ///
23    /// Measured in seconds since the Unix epoch.
24    pub created: Timestamp,
25
26    /// The hashed ID derived from the device ID from the card network associated with the token.
27    pub device_fingerprint: Option<String>,
28
29    /// The last four digits of the token.
30    #[serde(skip_serializing_if = "Option::is_none")]
31    pub last4: Option<String>,
32
33    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
34    pub livemode: bool,
35
36    /// The token service provider / card network associated with the token.
37    pub network: IssuingTokenNetwork,
38
39    #[serde(skip_serializing_if = "Option::is_none")]
40    pub network_data: Option<IssuingNetworkTokenNetworkData>,
41
42    /// Time at which the token was last updated by the card network.
43    ///
44    /// Measured in seconds since the Unix epoch.
45    pub network_updated_at: Timestamp,
46
47    /// The usage state of the token.
48    pub status: IssuingTokenStatus,
49
50    /// The digital wallet for this token, if one was used.
51    #[serde(skip_serializing_if = "Option::is_none")]
52    pub wallet_provider: Option<IssuingTokenWalletProvider>,
53}
54
55impl Object for IssuingToken {
56    type Id = IssuingTokenId;
57    fn id(&self) -> Self::Id {
58        self.id.clone()
59    }
60    fn object(&self) -> &'static str {
61        "issuing.token"
62    }
63}
64
65#[derive(Clone, Debug, Default, Deserialize, Serialize)]
66pub struct IssuingNetworkTokenNetworkData {
67    #[serde(skip_serializing_if = "Option::is_none")]
68    pub device: Option<IssuingNetworkTokenDevice>,
69
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub mastercard: Option<IssuingNetworkTokenMastercard>,
72
73    /// The network that the token is associated with.
74    ///
75    /// An additional hash is included with a name matching this value, containing tokenization data specific to the card network.
76    #[serde(rename = "type")]
77    pub type_: IssuingNetworkTokenNetworkDataType,
78
79    #[serde(skip_serializing_if = "Option::is_none")]
80    pub visa: Option<IssuingNetworkTokenVisa>,
81
82    #[serde(skip_serializing_if = "Option::is_none")]
83    pub wallet_provider: Option<IssuingNetworkTokenWalletProvider>,
84}
85
86#[derive(Clone, Debug, Default, Deserialize, Serialize)]
87pub struct IssuingNetworkTokenDevice {
88    /// An obfuscated ID derived from the device ID.
89    #[serde(skip_serializing_if = "Option::is_none")]
90    pub device_fingerprint: Option<String>,
91
92    /// The IP address of the device at provisioning time.
93    #[serde(skip_serializing_if = "Option::is_none")]
94    pub ip_address: Option<String>,
95
96    /// The geographic latitude/longitude coordinates of the device at provisioning time.
97    ///
98    /// The format is [+-]decimal/[+-]decimal.
99    #[serde(skip_serializing_if = "Option::is_none")]
100    pub location: Option<String>,
101
102    /// The name of the device used for tokenization.
103    #[serde(skip_serializing_if = "Option::is_none")]
104    pub name: Option<String>,
105
106    /// The phone number of the device used for tokenization.
107    #[serde(skip_serializing_if = "Option::is_none")]
108    pub phone_number: Option<String>,
109
110    /// The type of device used for tokenization.
111    #[serde(rename = "type")]
112    #[serde(skip_serializing_if = "Option::is_none")]
113    pub type_: Option<IssuingNetworkTokenDeviceType>,
114}
115
116#[derive(Clone, Debug, Default, Deserialize, Serialize)]
117pub struct IssuingNetworkTokenMastercard {
118    /// A unique reference ID from MasterCard to represent the card account number.
119    #[serde(skip_serializing_if = "Option::is_none")]
120    pub card_reference_id: Option<String>,
121
122    /// The network-unique identifier for the token.
123    pub token_reference_id: String,
124
125    /// The ID of the entity requesting tokenization, specific to MasterCard.
126    pub token_requestor_id: String,
127
128    /// The name of the entity requesting tokenization, if known.
129    ///
130    /// This is directly provided from MasterCard.
131    #[serde(skip_serializing_if = "Option::is_none")]
132    pub token_requestor_name: Option<String>,
133}
134
135#[derive(Clone, Debug, Default, Deserialize, Serialize)]
136pub struct IssuingNetworkTokenVisa {
137    /// A unique reference ID from Visa to represent the card account number.
138    pub card_reference_id: String,
139
140    /// The network-unique identifier for the token.
141    pub token_reference_id: String,
142
143    /// The ID of the entity requesting tokenization, specific to Visa.
144    pub token_requestor_id: String,
145
146    /// Degree of risk associated with the token between `01` and `99`, with higher number indicating higher risk.
147    ///
148    /// A `00` value indicates the token was not scored by Visa.
149    #[serde(skip_serializing_if = "Option::is_none")]
150    pub token_risk_score: Option<String>,
151}
152
153#[derive(Clone, Debug, Default, Deserialize, Serialize)]
154pub struct IssuingNetworkTokenWalletProvider {
155    /// The wallet provider-given account ID of the digital wallet the token belongs to.
156    #[serde(skip_serializing_if = "Option::is_none")]
157    pub account_id: Option<String>,
158
159    /// An evaluation on the trustworthiness of the wallet account between 1 and 5.
160    ///
161    /// A higher score indicates more trustworthy.
162    #[serde(skip_serializing_if = "Option::is_none")]
163    pub account_trust_score: Option<i64>,
164
165    /// The method used for tokenizing a card.
166    #[serde(skip_serializing_if = "Option::is_none")]
167    pub card_number_source: Option<IssuingNetworkTokenWalletProviderCardNumberSource>,
168
169    #[serde(skip_serializing_if = "Option::is_none")]
170    pub cardholder_address: Option<IssuingNetworkTokenAddress>,
171
172    /// The name of the cardholder tokenizing the card.
173    #[serde(skip_serializing_if = "Option::is_none")]
174    pub cardholder_name: Option<String>,
175
176    /// An evaluation on the trustworthiness of the device.
177    ///
178    /// A higher score indicates more trustworthy.
179    #[serde(skip_serializing_if = "Option::is_none")]
180    pub device_trust_score: Option<i64>,
181
182    /// The hashed email address of the cardholder's account with the wallet provider.
183    #[serde(skip_serializing_if = "Option::is_none")]
184    pub hashed_account_email_address: Option<String>,
185
186    /// The reasons for suggested tokenization given by the card network.
187    #[serde(skip_serializing_if = "Option::is_none")]
188    pub reason_codes: Option<Vec<IssuingNetworkTokenWalletProviderReasonCodes>>,
189
190    /// The recommendation on responding to the tokenization request.
191    #[serde(skip_serializing_if = "Option::is_none")]
192    pub suggested_decision: Option<IssuingNetworkTokenWalletProviderSuggestedDecision>,
193
194    /// The version of the standard for mapping reason codes followed by the wallet provider.
195    #[serde(skip_serializing_if = "Option::is_none")]
196    pub suggested_decision_version: Option<String>,
197}
198
199#[derive(Clone, Debug, Default, Deserialize, Serialize)]
200pub struct IssuingNetworkTokenAddress {
201    /// The street address of the cardholder tokenizing the card.
202    pub line1: String,
203
204    /// The postal code of the cardholder tokenizing the card.
205    pub postal_code: String,
206}
207
208/// An enum representing the possible values of an `IssuingNetworkTokenDevice`'s `type` field.
209#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
210#[serde(rename_all = "snake_case")]
211pub enum IssuingNetworkTokenDeviceType {
212    Other,
213    Phone,
214    Watch,
215}
216
217impl IssuingNetworkTokenDeviceType {
218    pub fn as_str(self) -> &'static str {
219        match self {
220            IssuingNetworkTokenDeviceType::Other => "other",
221            IssuingNetworkTokenDeviceType::Phone => "phone",
222            IssuingNetworkTokenDeviceType::Watch => "watch",
223        }
224    }
225}
226
227impl AsRef<str> for IssuingNetworkTokenDeviceType {
228    fn as_ref(&self) -> &str {
229        self.as_str()
230    }
231}
232
233impl std::fmt::Display for IssuingNetworkTokenDeviceType {
234    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
235        self.as_str().fmt(f)
236    }
237}
238impl std::default::Default for IssuingNetworkTokenDeviceType {
239    fn default() -> Self {
240        Self::Other
241    }
242}
243
244/// An enum representing the possible values of an `IssuingNetworkTokenNetworkData`'s `type` field.
245#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
246#[serde(rename_all = "snake_case")]
247pub enum IssuingNetworkTokenNetworkDataType {
248    Mastercard,
249    Visa,
250}
251
252impl IssuingNetworkTokenNetworkDataType {
253    pub fn as_str(self) -> &'static str {
254        match self {
255            IssuingNetworkTokenNetworkDataType::Mastercard => "mastercard",
256            IssuingNetworkTokenNetworkDataType::Visa => "visa",
257        }
258    }
259}
260
261impl AsRef<str> for IssuingNetworkTokenNetworkDataType {
262    fn as_ref(&self) -> &str {
263        self.as_str()
264    }
265}
266
267impl std::fmt::Display for IssuingNetworkTokenNetworkDataType {
268    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
269        self.as_str().fmt(f)
270    }
271}
272impl std::default::Default for IssuingNetworkTokenNetworkDataType {
273    fn default() -> Self {
274        Self::Mastercard
275    }
276}
277
278/// An enum representing the possible values of an `IssuingNetworkTokenWalletProvider`'s `card_number_source` field.
279#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
280#[serde(rename_all = "snake_case")]
281pub enum IssuingNetworkTokenWalletProviderCardNumberSource {
282    App,
283    Manual,
284    OnFile,
285    Other,
286}
287
288impl IssuingNetworkTokenWalletProviderCardNumberSource {
289    pub fn as_str(self) -> &'static str {
290        match self {
291            IssuingNetworkTokenWalletProviderCardNumberSource::App => "app",
292            IssuingNetworkTokenWalletProviderCardNumberSource::Manual => "manual",
293            IssuingNetworkTokenWalletProviderCardNumberSource::OnFile => "on_file",
294            IssuingNetworkTokenWalletProviderCardNumberSource::Other => "other",
295        }
296    }
297}
298
299impl AsRef<str> for IssuingNetworkTokenWalletProviderCardNumberSource {
300    fn as_ref(&self) -> &str {
301        self.as_str()
302    }
303}
304
305impl std::fmt::Display for IssuingNetworkTokenWalletProviderCardNumberSource {
306    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
307        self.as_str().fmt(f)
308    }
309}
310impl std::default::Default for IssuingNetworkTokenWalletProviderCardNumberSource {
311    fn default() -> Self {
312        Self::App
313    }
314}
315
316/// An enum representing the possible values of an `IssuingNetworkTokenWalletProvider`'s `reason_codes` field.
317#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
318#[serde(rename_all = "snake_case")]
319pub enum IssuingNetworkTokenWalletProviderReasonCodes {
320    AccountCardTooNew,
321    AccountRecentlyChanged,
322    AccountTooNew,
323    AccountTooNewSinceLaunch,
324    AdditionalDevice,
325    DataExpired,
326    DeferIdVDecision,
327    DeviceRecentlyLost,
328    GoodActivityHistory,
329    HasSuspendedTokens,
330    HighRisk,
331    InactiveAccount,
332    LongAccountTenure,
333    LowAccountScore,
334    LowDeviceScore,
335    LowPhoneNumberScore,
336    NetworkServiceError,
337    OutsideHomeTerritory,
338    ProvisioningCardholderMismatch,
339    ProvisioningDeviceAndCardholderMismatch,
340    ProvisioningDeviceMismatch,
341    SameDeviceNoPriorAuthentication,
342    SameDeviceSuccessfulPriorAuthentication,
343    SoftwareUpdate,
344    SuspiciousActivity,
345    TooManyDifferentCardholders,
346    TooManyRecentAttempts,
347    TooManyRecentTokens,
348}
349
350impl IssuingNetworkTokenWalletProviderReasonCodes {
351    pub fn as_str(self) -> &'static str {
352        match self {
353            IssuingNetworkTokenWalletProviderReasonCodes::AccountCardTooNew => "account_card_too_new",
354            IssuingNetworkTokenWalletProviderReasonCodes::AccountRecentlyChanged => "account_recently_changed",
355            IssuingNetworkTokenWalletProviderReasonCodes::AccountTooNew => "account_too_new",
356            IssuingNetworkTokenWalletProviderReasonCodes::AccountTooNewSinceLaunch => "account_too_new_since_launch",
357            IssuingNetworkTokenWalletProviderReasonCodes::AdditionalDevice => "additional_device",
358            IssuingNetworkTokenWalletProviderReasonCodes::DataExpired => "data_expired",
359            IssuingNetworkTokenWalletProviderReasonCodes::DeferIdVDecision => "defer_id_v_decision",
360            IssuingNetworkTokenWalletProviderReasonCodes::DeviceRecentlyLost => "device_recently_lost",
361            IssuingNetworkTokenWalletProviderReasonCodes::GoodActivityHistory => "good_activity_history",
362            IssuingNetworkTokenWalletProviderReasonCodes::HasSuspendedTokens => "has_suspended_tokens",
363            IssuingNetworkTokenWalletProviderReasonCodes::HighRisk => "high_risk",
364            IssuingNetworkTokenWalletProviderReasonCodes::InactiveAccount => "inactive_account",
365            IssuingNetworkTokenWalletProviderReasonCodes::LongAccountTenure => "long_account_tenure",
366            IssuingNetworkTokenWalletProviderReasonCodes::LowAccountScore => "low_account_score",
367            IssuingNetworkTokenWalletProviderReasonCodes::LowDeviceScore => "low_device_score",
368            IssuingNetworkTokenWalletProviderReasonCodes::LowPhoneNumberScore => "low_phone_number_score",
369            IssuingNetworkTokenWalletProviderReasonCodes::NetworkServiceError => "network_service_error",
370            IssuingNetworkTokenWalletProviderReasonCodes::OutsideHomeTerritory => "outside_home_territory",
371            IssuingNetworkTokenWalletProviderReasonCodes::ProvisioningCardholderMismatch => "provisioning_cardholder_mismatch",
372            IssuingNetworkTokenWalletProviderReasonCodes::ProvisioningDeviceAndCardholderMismatch => "provisioning_device_and_cardholder_mismatch",
373            IssuingNetworkTokenWalletProviderReasonCodes::ProvisioningDeviceMismatch => "provisioning_device_mismatch",
374            IssuingNetworkTokenWalletProviderReasonCodes::SameDeviceNoPriorAuthentication => "same_device_no_prior_authentication",
375            IssuingNetworkTokenWalletProviderReasonCodes::SameDeviceSuccessfulPriorAuthentication => "same_device_successful_prior_authentication",
376            IssuingNetworkTokenWalletProviderReasonCodes::SoftwareUpdate => "software_update",
377            IssuingNetworkTokenWalletProviderReasonCodes::SuspiciousActivity => "suspicious_activity",
378            IssuingNetworkTokenWalletProviderReasonCodes::TooManyDifferentCardholders => "too_many_different_cardholders",
379            IssuingNetworkTokenWalletProviderReasonCodes::TooManyRecentAttempts => "too_many_recent_attempts",
380            IssuingNetworkTokenWalletProviderReasonCodes::TooManyRecentTokens => "too_many_recent_tokens",
381        }
382    }
383}
384
385impl AsRef<str> for IssuingNetworkTokenWalletProviderReasonCodes {
386    fn as_ref(&self) -> &str {
387        self.as_str()
388    }
389}
390
391impl std::fmt::Display for IssuingNetworkTokenWalletProviderReasonCodes {
392    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
393        self.as_str().fmt(f)
394    }
395}
396impl std::default::Default for IssuingNetworkTokenWalletProviderReasonCodes {
397    fn default() -> Self {
398        Self::AccountCardTooNew
399    }
400}
401
402/// An enum representing the possible values of an `IssuingNetworkTokenWalletProvider`'s `suggested_decision` field.
403#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
404#[serde(rename_all = "snake_case")]
405pub enum IssuingNetworkTokenWalletProviderSuggestedDecision {
406    Approve,
407    Decline,
408    RequireAuth,
409}
410
411impl IssuingNetworkTokenWalletProviderSuggestedDecision {
412    pub fn as_str(self) -> &'static str {
413        match self {
414            IssuingNetworkTokenWalletProviderSuggestedDecision::Approve => "approve",
415            IssuingNetworkTokenWalletProviderSuggestedDecision::Decline => "decline",
416            IssuingNetworkTokenWalletProviderSuggestedDecision::RequireAuth => "require_auth",
417        }
418    }
419}
420
421impl AsRef<str> for IssuingNetworkTokenWalletProviderSuggestedDecision {
422    fn as_ref(&self) -> &str {
423        self.as_str()
424    }
425}
426
427impl std::fmt::Display for IssuingNetworkTokenWalletProviderSuggestedDecision {
428    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
429        self.as_str().fmt(f)
430    }
431}
432impl std::default::Default for IssuingNetworkTokenWalletProviderSuggestedDecision {
433    fn default() -> Self {
434        Self::Approve
435    }
436}
437
438/// An enum representing the possible values of an `IssuingToken`'s `network` field.
439#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
440#[serde(rename_all = "snake_case")]
441pub enum IssuingTokenNetwork {
442    Mastercard,
443    Visa,
444}
445
446impl IssuingTokenNetwork {
447    pub fn as_str(self) -> &'static str {
448        match self {
449            IssuingTokenNetwork::Mastercard => "mastercard",
450            IssuingTokenNetwork::Visa => "visa",
451        }
452    }
453}
454
455impl AsRef<str> for IssuingTokenNetwork {
456    fn as_ref(&self) -> &str {
457        self.as_str()
458    }
459}
460
461impl std::fmt::Display for IssuingTokenNetwork {
462    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
463        self.as_str().fmt(f)
464    }
465}
466impl std::default::Default for IssuingTokenNetwork {
467    fn default() -> Self {
468        Self::Mastercard
469    }
470}
471
472/// An enum representing the possible values of an `IssuingToken`'s `status` field.
473#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
474#[serde(rename_all = "snake_case")]
475pub enum IssuingTokenStatus {
476    Active,
477    Deleted,
478    Requested,
479    Suspended,
480}
481
482impl IssuingTokenStatus {
483    pub fn as_str(self) -> &'static str {
484        match self {
485            IssuingTokenStatus::Active => "active",
486            IssuingTokenStatus::Deleted => "deleted",
487            IssuingTokenStatus::Requested => "requested",
488            IssuingTokenStatus::Suspended => "suspended",
489        }
490    }
491}
492
493impl AsRef<str> for IssuingTokenStatus {
494    fn as_ref(&self) -> &str {
495        self.as_str()
496    }
497}
498
499impl std::fmt::Display for IssuingTokenStatus {
500    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
501        self.as_str().fmt(f)
502    }
503}
504impl std::default::Default for IssuingTokenStatus {
505    fn default() -> Self {
506        Self::Active
507    }
508}
509
510/// An enum representing the possible values of an `IssuingToken`'s `wallet_provider` field.
511#[derive(Copy, Clone, Debug, Deserialize, Serialize, Eq, PartialEq)]
512#[serde(rename_all = "snake_case")]
513pub enum IssuingTokenWalletProvider {
514    ApplePay,
515    GooglePay,
516    SamsungPay,
517}
518
519impl IssuingTokenWalletProvider {
520    pub fn as_str(self) -> &'static str {
521        match self {
522            IssuingTokenWalletProvider::ApplePay => "apple_pay",
523            IssuingTokenWalletProvider::GooglePay => "google_pay",
524            IssuingTokenWalletProvider::SamsungPay => "samsung_pay",
525        }
526    }
527}
528
529impl AsRef<str> for IssuingTokenWalletProvider {
530    fn as_ref(&self) -> &str {
531        self.as_str()
532    }
533}
534
535impl std::fmt::Display for IssuingTokenWalletProvider {
536    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
537        self.as_str().fmt(f)
538    }
539}
540impl std::default::Default for IssuingTokenWalletProvider {
541    fn default() -> Self {
542        Self::ApplePay
543    }
544}