stripe/model/token.rs
1use serde::{Serialize, Deserialize};
2use super::{BankAccount, Card};
3/**Tokenization is the process Stripe uses to collect sensitive card or bank
4account details, or personally identifiable information (PII), directly from
5your customers in a secure manner. A token representing this information is
6returned to your server to use. Use our
7[recommended payments integrations](https://stripe.com/docs/payments) to perform this process
8on the client-side. This guarantees that no sensitive card data touches your server,
9and allows your integration to operate in a PCI-compliant way.
10
11If you can't use client-side tokenization, you can also create tokens using
12the API with either your publishable or secret API key. If
13your integration uses this method, you're responsible for any PCI compliance
14that it might require, and you must keep your secret API key safe. Unlike with
15client-side tokenization, your customer's information isn't sent directly to
16Stripe, so we can't determine how it's handled or stored.
17
18You can't store or use tokens more than once. To store card or bank account
19information for later use, create [Customer](https://stripe.com/docs/api#customers)
20objects or [Custom accounts](https://stripe.com/docs/api#external_accounts).
21[Radar](https://stripe.com/docs/radar), our integrated solution for automatic fraud protection,
22performs best with integrations that use client-side tokenization.*/
23#[derive(Debug, Clone, Serialize, Deserialize, Default)]
24pub struct Token {
25 /**These bank accounts are payment methods on `Customer` objects.
26
27On the other hand [External Accounts](https://stripe.com/docs/api#external_accounts) are transfer
28destinations on `Account` objects for [Custom accounts](https://stripe.com/docs/connect/custom-accounts).
29They can be bank accounts or debit cards as well, and are documented in the links above.
30
31Related guide: [Bank debits and transfers](https://stripe.com/docs/payments/bank-debits-transfers)*/
32 #[serde(skip_serializing_if = "Option::is_none")]
33 pub bank_account: Option<BankAccount>,
34 /**You can store multiple cards on a customer in order to charge the customer
35later. You can also store multiple debit cards on a recipient in order to
36transfer to those cards later.
37
38Related guide: [Card payments with Sources](https://stripe.com/docs/sources/cards)*/
39 #[serde(skip_serializing_if = "Option::is_none")]
40 pub card: Option<Card>,
41 ///IP address of the client that generates the token.
42 #[serde(skip_serializing_if = "Option::is_none")]
43 pub client_ip: Option<String>,
44 ///Time at which the object was created. Measured in seconds since the Unix epoch.
45 pub created: i64,
46 ///Unique identifier for the object.
47 pub id: String,
48 ///Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
49 pub livemode: bool,
50 ///String representing the object's type. Objects of the same type share the same value.
51 pub object: String,
52 ///Type of the token: `account`, `bank_account`, `card`, or `pii`.
53 #[serde(rename = "type")]
54 pub type_: String,
55 ///Determines if you have already used this token (you can only use tokens once).
56 pub used: bool,
57}
58impl std::fmt::Display for Token {
59 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
60 write!(f, "{}", serde_json::to_string(self).unwrap())
61 }
62}