stripe/model/
setup_intent.rs

1use serde::{Serialize, Deserialize};
2/**A SetupIntent guides you through the process of setting up and saving a customer's payment credentials for future payments.
3For example, you can use a SetupIntent to set up and save your customer's card without immediately collecting a payment.
4Later, you can use [PaymentIntents](https://stripe.com/docs/api#payment_intents) to drive the payment flow.
5
6Create a SetupIntent when you're ready to collect your customer's payment credentials.
7Don't maintain long-lived, unconfirmed SetupIntents because they might not be valid.
8The SetupIntent transitions through multiple [statuses](https://stripe.com/docs/payments/intents#intent-statuses) as it guides
9you through the setup process.
10
11Successful SetupIntents result in payment credentials that are optimized for future payments.
12For example, cardholders in [certain regions](/guides/strong-customer-authentication) might need to be run through
13[Strong Customer Authentication](https://stripe.com/docs/strong-customer-authentication) during payment method collection
14to streamline later [off-session payments](https://stripe.com/docs/payments/setup-intents).
15If you use the SetupIntent with a [Customer](https://stripe.com/docs/api#setup_intent_object-customer),
16it automatically attaches the resulting payment method to that Customer after successful setup.
17We recommend using SetupIntents or [setup_future_usage](https://stripe.com/docs/api#payment_intent_object-setup_future_usage) on
18PaymentIntents to save payment methods to prevent saving invalid or unoptimized payment methods.
19
20By using SetupIntents, you can reduce friction for your customers, even as regulations change over time.
21
22Related guide: [Setup Intents API](https://stripe.com/docs/payments/setup-intents)*/
23#[derive(Debug, Clone, Serialize, Deserialize, Default)]
24pub struct SetupIntent {
25    ///ID of the Connect application that created the SetupIntent.
26    #[serde(skip_serializing_if = "Option::is_none")]
27    pub application: Option<serde_json::Value>,
28    /**If present, the SetupIntent's payment method will be attached to the in-context Stripe Account.
29
30It can only be used for this Stripe Account’s own money movement flows like InboundTransfer and OutboundTransfers. It cannot be set to true when setting up a PaymentMethod for a Customer, and defaults to false when attaching a PaymentMethod to a Customer.*/
31    #[serde(skip_serializing_if = "Option::is_none")]
32    pub attach_to_self: Option<bool>,
33    ///Settings for dynamic payment methods compatible with this Setup Intent
34    #[serde(skip_serializing_if = "Option::is_none")]
35    pub automatic_payment_methods: Option<serde_json::Value>,
36    ///Reason for cancellation of this SetupIntent, one of `abandoned`, `requested_by_customer`, or `duplicate`.
37    #[serde(skip_serializing_if = "Option::is_none")]
38    pub cancellation_reason: Option<String>,
39    /**The client secret of this SetupIntent. Used for client-side retrieval using a publishable key.
40
41The client secret can be used to complete payment setup from your frontend. It should not be stored, logged, or exposed to anyone other than the customer. Make sure that you have TLS enabled on any page that includes the client secret.*/
42    #[serde(skip_serializing_if = "Option::is_none")]
43    pub client_secret: Option<String>,
44    ///Time at which the object was created. Measured in seconds since the Unix epoch.
45    pub created: i64,
46    /**ID of the Customer this SetupIntent belongs to, if one exists.
47
48If present, the SetupIntent's payment method will be attached to the Customer on successful setup. Payment methods attached to other Customers cannot be used with this SetupIntent.*/
49    #[serde(skip_serializing_if = "Option::is_none")]
50    pub customer: Option<serde_json::Value>,
51    ///An arbitrary string attached to the object. Often useful for displaying to users.
52    #[serde(skip_serializing_if = "Option::is_none")]
53    pub description: Option<String>,
54    /**Indicates the directions of money movement for which this payment method is intended to be used.
55
56Include `inbound` if you intend to use the payment method as the origin to pull funds from. Include `outbound` if you intend to use the payment method as the destination to send funds to. You can include both if you intend to use the payment method for both purposes.*/
57    #[serde(skip_serializing_if = "Option::is_none")]
58    pub flow_directions: Option<Vec<String>>,
59    ///Unique identifier for the object.
60    pub id: String,
61    ///The error encountered in the previous SetupIntent confirmation.
62    #[serde(skip_serializing_if = "Option::is_none")]
63    pub last_setup_error: Option<serde_json::Value>,
64    ///The most recent SetupAttempt for this SetupIntent.
65    #[serde(skip_serializing_if = "Option::is_none")]
66    pub latest_attempt: Option<serde_json::Value>,
67    ///Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
68    pub livemode: bool,
69    ///ID of the multi use Mandate generated by the SetupIntent.
70    #[serde(skip_serializing_if = "Option::is_none")]
71    pub mandate: Option<serde_json::Value>,
72    ///Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object. This can be useful for storing additional information about the object in a structured format.
73    #[serde(skip_serializing_if = "Option::is_none")]
74    pub metadata: Option<serde_json::Value>,
75    ///If present, this property tells you what actions you need to take in order for your customer to continue payment setup.
76    #[serde(skip_serializing_if = "Option::is_none")]
77    pub next_action: Option<serde_json::Value>,
78    ///String representing the object's type. Objects of the same type share the same value.
79    pub object: String,
80    ///The account (if any) for which the setup is intended.
81    #[serde(skip_serializing_if = "Option::is_none")]
82    pub on_behalf_of: Option<serde_json::Value>,
83    ///ID of the payment method used with this SetupIntent.
84    #[serde(skip_serializing_if = "Option::is_none")]
85    pub payment_method: Option<serde_json::Value>,
86    ///Information about the payment method configuration used for this Setup Intent.
87    #[serde(skip_serializing_if = "Option::is_none")]
88    pub payment_method_configuration_details: Option<serde_json::Value>,
89    ///Payment method-specific configuration for this SetupIntent.
90    #[serde(skip_serializing_if = "Option::is_none")]
91    pub payment_method_options: Option<serde_json::Value>,
92    ///The list of payment method types (e.g. card) that this SetupIntent is allowed to set up.
93    pub payment_method_types: Vec<String>,
94    ///ID of the single_use Mandate generated by the SetupIntent.
95    #[serde(skip_serializing_if = "Option::is_none")]
96    pub single_use_mandate: Option<serde_json::Value>,
97    ///[Status](https://stripe.com/docs/payments/intents#intent-statuses) of this SetupIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `canceled`, or `succeeded`.
98    pub status: String,
99    /**Indicates how the payment method is intended to be used in the future.
100
101Use `on_session` if you intend to only reuse the payment method when the customer is in your checkout flow. Use `off_session` if your customer may or may not be in your checkout flow. If not provided, this value defaults to `off_session`.*/
102    pub usage: String,
103}
104impl std::fmt::Display for SetupIntent {
105    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> Result<(), std::fmt::Error> {
106        write!(f, "{}", serde_json::to_string(self).unwrap())
107    }
108}