Skip to main content

stripe_shared/
payment_intent.rs

1/// A PaymentIntent guides you through the process of collecting a payment from your customer.
2/// We recommend that you create exactly one PaymentIntent for each order or
3/// customer session in your system. You can reference the PaymentIntent later to
4/// see the history of payment attempts for a particular session.
5///
6/// A PaymentIntent transitions through
7/// [multiple statuses](/payments/paymentintents/lifecycle)
8/// throughout its lifetime as it interfaces with Stripe.js to perform
9/// authentication flows and ultimately creates at most one successful charge.
10///
11/// Related guide: [Payment Intents API](https://docs.stripe.com/payments/payment-intents)
12///
13/// For more details see <<https://stripe.com/docs/api/payment_intents/object>>.
14#[derive(Clone)]
15#[cfg_attr(not(feature = "redact-generated-debug"), derive(Debug))]
16#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
17pub struct PaymentIntent {
18    /// Amount intended to be collected by this PaymentIntent.
19    /// A positive integer representing how much to charge in the [smallest currency unit](https://docs.stripe.com/currencies#zero-decimal) (e.g., 100 cents to charge $1.00 or 100 to charge ¥100, a zero-decimal currency).
20    /// The minimum amount is $0.50 US or [equivalent in charge currency](https://docs.stripe.com/currencies#minimum-and-maximum-charge-amounts).
21    /// The amount value supports up to eight digits (e.g., a value of 99999999 for a USD charge of $999,999.99).
22    pub amount: i64,
23    /// Amount that can be captured from this PaymentIntent.
24    pub amount_capturable: i64,
25    pub amount_details: Option<stripe_shared::PaymentFlowsAmountDetails>,
26    /// Amount that this PaymentIntent collects.
27    pub amount_received: i64,
28    /// ID of the Connect application that created the PaymentIntent.
29    pub application: Option<stripe_types::Expandable<stripe_shared::Application>>,
30    /// The amount of the application fee (if any) that will be requested to be applied to the payment and transferred to the application owner's Stripe account.
31    /// The amount of the application fee collected will be capped at the total amount captured.
32    /// For more information, see the PaymentIntents [use case for connected accounts](https://docs.stripe.com/payments/connected-accounts).
33    pub application_fee_amount: Option<i64>,
34    /// Settings to configure compatible payment methods from the [Stripe Dashboard](https://dashboard.stripe.com/settings/payment_methods).
35    pub automatic_payment_methods:
36        Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>,
37    /// Populated when `status` is `canceled`, this is the time at which the PaymentIntent was canceled.
38    /// Measured in seconds since the Unix epoch.
39    pub canceled_at: Option<stripe_types::Timestamp>,
40    /// Reason for cancellation of this PaymentIntent, either user-provided (`duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`) or generated by Stripe internally (`failed_invoice`, `void_invoice`, `automatic`, or `expired`).
41    pub cancellation_reason: Option<PaymentIntentCancellationReason>,
42    /// Controls when the funds will be captured from the customer's account.
43    pub capture_method: stripe_shared::PaymentIntentCaptureMethod,
44    /// The client secret of this PaymentIntent. Used for client-side retrieval using a publishable key.
45    ///
46    /// The client secret can be used to complete a payment from your frontend.
47    /// It should not be stored, logged, or exposed to anyone other than the customer.
48    /// Make sure that you have TLS enabled on any page that includes the client secret.
49    ///
50    /// Refer to our docs to [accept a payment](https://docs.stripe.com/payments/accept-a-payment?ui=elements) and learn about how `client_secret` should be handled.
51    pub client_secret: Option<String>,
52    /// Describes whether we can confirm this PaymentIntent automatically, or if it requires customer action to confirm the payment.
53    pub confirmation_method: stripe_shared::PaymentIntentConfirmationMethod,
54    /// Time at which the object was created. Measured in seconds since the Unix epoch.
55    pub created: stripe_types::Timestamp,
56    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
57    /// Must be a [supported currency](https://stripe.com/docs/currencies).
58    pub currency: stripe_types::Currency,
59    /// ID of the Customer this PaymentIntent belongs to, if one exists.
60    ///
61    /// Payment methods attached to other Customers cannot be used with this PaymentIntent.
62    ///
63    /// If [setup_future_usage](https://api.stripe.com#payment_intent_object-setup_future_usage) is set and this PaymentIntent's payment method is not `card_present`, then the payment method attaches to the Customer after the PaymentIntent has been confirmed and any required actions from the user are complete.
64    /// If the payment method is `card_present` and isn't a digital wallet, then a [generated_card](https://docs.stripe.com/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card is created and attached to the Customer instead.
65    pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
66    /// ID of the Account representing the customer that this PaymentIntent belongs to, if one exists.
67    ///
68    /// Payment methods attached to other Accounts cannot be used with this PaymentIntent.
69    ///
70    /// If [setup_future_usage](https://api.stripe.com#payment_intent_object-setup_future_usage) is set and this PaymentIntent's payment method is not `card_present`, then the payment method attaches to the Account after the PaymentIntent has been confirmed and any required actions from the user are complete.
71    /// If the payment method is `card_present` and isn't a digital wallet, then a [generated_card](https://docs.stripe.com/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card is created and attached to the Account instead.
72    pub customer_account: Option<String>,
73    /// An arbitrary string attached to the object. Often useful for displaying to users.
74    pub description: Option<String>,
75    /// The list of payment method types to exclude from use with this payment.
76    pub excluded_payment_method_types:
77        Option<Vec<stripe_shared::PaymentIntentExcludedPaymentMethodTypes>>,
78    pub hooks: Option<stripe_shared::PaymentFlowsPaymentIntentAsyncWorkflows>,
79    /// Unique identifier for the object.
80    pub id: stripe_shared::PaymentIntentId,
81    /// The payment error encountered in the previous PaymentIntent confirmation.
82    /// It will be cleared if the PaymentIntent is later updated for any reason.
83    pub last_payment_error: Option<Box<stripe_shared::ApiErrors>>,
84    /// ID of the latest [Charge object](https://docs.stripe.com/api/charges) created by this PaymentIntent.
85    /// This property is `null` until PaymentIntent confirmation is attempted.
86    pub latest_charge: Option<stripe_types::Expandable<stripe_shared::Charge>>,
87    /// If the object exists in live mode, the value is `true`.
88    /// If the object exists in test mode, the value is `false`.
89    pub livemode: bool,
90    /// Settings for Managed Payments.
91    pub managed_payments: Option<stripe_shared::SmorResourceManagedPayments>,
92    /// Set of [key-value pairs](https://docs.stripe.com/api/metadata) that you can attach to an object.
93    /// This can be useful for storing additional information about the object in a structured format.
94    /// Learn more about [storing information in metadata](https://docs.stripe.com/payments/payment-intents/creating-payment-intents#storing-information-in-metadata).
95    pub metadata: std::collections::HashMap<String, String>,
96    /// If present, this property tells you what actions you need to take in order for your customer to fulfill a payment using the provided source.
97    pub next_action: Option<stripe_shared::PaymentIntentNextAction>,
98    /// You can specify the settlement merchant as the
99    /// connected account using the `on_behalf_of` attribute on the charge.
100    /// See the PaymentIntents [use case for connected accounts](/payments/connected-accounts) for details.
101    pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
102    pub payment_details: Option<stripe_shared::PaymentFlowsPaymentDetails>,
103    /// ID of the payment method used in this PaymentIntent.
104    pub payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
105    /// Information about the [payment method configuration](https://docs.stripe.com/api/payment_method_configurations) used for this PaymentIntent.
106    pub payment_method_configuration_details:
107        Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>,
108    /// Payment-method-specific configuration for this PaymentIntent.
109    pub payment_method_options: Option<stripe_shared::PaymentIntentPaymentMethodOptions>,
110    /// The list of payment method types (e.g.
111    /// card) that this PaymentIntent is allowed to use.
112    /// A comprehensive list of valid payment method types can be found [here](https://docs.stripe.com/api/payment_methods/object#payment_method_object-type).
113    pub payment_method_types: Vec<String>,
114    pub presentment_details: Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>,
115    /// If present, this property tells you about the processing state of the payment.
116    pub processing: Option<stripe_shared::PaymentIntentProcessing>,
117    /// Email address that the receipt for the resulting payment will be sent to.
118    /// If `receipt_email` is specified for a payment in live mode, a receipt will be sent regardless of your [email settings](https://dashboard.stripe.com/account/emails).
119    pub receipt_email: Option<String>,
120    /// ID of the review associated with this PaymentIntent, if any.
121    pub review: Option<stripe_types::Expandable<stripe_shared::Review>>,
122    /// Indicates that you intend to make future payments with this PaymentIntent's payment method.
123    ///
124    /// If you provide a Customer with the PaymentIntent, you can use this parameter to [attach the payment method](/payments/save-during-payment) to the Customer after the PaymentIntent is confirmed and the customer completes any required actions.
125    /// If you don't provide a Customer, you can still [attach](/api/payment_methods/attach) the payment method to a Customer after the transaction completes.
126    ///
127    /// If the payment method is `card_present` and isn't a digital wallet, Stripe creates and attaches a [generated_card](/api/charges/object#charge_object-payment_method_details-card_present-generated_card) payment method representing the card to the Customer instead.
128    ///
129    /// When processing card payments, Stripe uses `setup_future_usage` to help you comply with regional legislation and network rules, such as [SCA](/strong-customer-authentication).
130    pub setup_future_usage: Option<stripe_shared::PaymentIntentSetupFutureUsage>,
131    /// Shipping information for this PaymentIntent.
132    pub shipping: Option<stripe_shared::Shipping>,
133    /// This is a legacy field that will be removed in the future.
134    /// It is the ID of the Source object that is associated with this PaymentIntent, if one was supplied.
135    pub source: Option<stripe_types::Expandable<stripe_shared::PaymentSource>>,
136    /// Text that appears on the customer's statement as the statement descriptor for a non-card charge.
137    /// This value overrides the account's default statement descriptor.
138    /// For information about requirements, including the 22-character limit, see [the Statement Descriptor docs](https://docs.stripe.com/get-started/account/statement-descriptors).
139    ///
140    /// Setting this value for a card charge returns an error.
141    /// For card charges, set the [statement_descriptor_suffix](https://docs.stripe.com/get-started/account/statement-descriptors#dynamic) instead.
142    pub statement_descriptor: Option<String>,
143    /// Provides information about a card charge.
144    /// Concatenated to the account's [statement descriptor prefix](https://docs.stripe.com/get-started/account/statement-descriptors#static) to form the complete statement descriptor that appears on the customer's statement.
145    pub statement_descriptor_suffix: Option<String>,
146    /// Status of this PaymentIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `requires_capture`, `canceled`, or `succeeded`.
147    /// Read more about each PaymentIntent [status](https://docs.stripe.com/payments/intents#intent-statuses).
148    pub status: PaymentIntentStatus,
149    /// The data that automatically creates a Transfer after the payment finalizes.
150    /// Learn more about the [use case for connected accounts](https://docs.stripe.com/payments/connected-accounts).
151    pub transfer_data: Option<stripe_shared::TransferData>,
152    /// A string that identifies the resulting payment as part of a group.
153    /// Learn more about the [use case for connected accounts](https://docs.stripe.com/connect/separate-charges-and-transfers).
154    pub transfer_group: Option<String>,
155}
156#[cfg(feature = "redact-generated-debug")]
157impl std::fmt::Debug for PaymentIntent {
158    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
159        f.debug_struct("PaymentIntent").finish_non_exhaustive()
160    }
161}
162#[doc(hidden)]
163pub struct PaymentIntentBuilder {
164    amount: Option<i64>,
165    amount_capturable: Option<i64>,
166    amount_details: Option<Option<stripe_shared::PaymentFlowsAmountDetails>>,
167    amount_received: Option<i64>,
168    application: Option<Option<stripe_types::Expandable<stripe_shared::Application>>>,
169    application_fee_amount: Option<Option<i64>>,
170    automatic_payment_methods:
171        Option<Option<stripe_shared::PaymentFlowsAutomaticPaymentMethodsPaymentIntent>>,
172    canceled_at: Option<Option<stripe_types::Timestamp>>,
173    cancellation_reason: Option<Option<PaymentIntentCancellationReason>>,
174    capture_method: Option<stripe_shared::PaymentIntentCaptureMethod>,
175    client_secret: Option<Option<String>>,
176    confirmation_method: Option<stripe_shared::PaymentIntentConfirmationMethod>,
177    created: Option<stripe_types::Timestamp>,
178    currency: Option<stripe_types::Currency>,
179    customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
180    customer_account: Option<Option<String>>,
181    description: Option<Option<String>>,
182    excluded_payment_method_types:
183        Option<Option<Vec<stripe_shared::PaymentIntentExcludedPaymentMethodTypes>>>,
184    hooks: Option<Option<stripe_shared::PaymentFlowsPaymentIntentAsyncWorkflows>>,
185    id: Option<stripe_shared::PaymentIntentId>,
186    last_payment_error: Option<Option<Box<stripe_shared::ApiErrors>>>,
187    latest_charge: Option<Option<stripe_types::Expandable<stripe_shared::Charge>>>,
188    livemode: Option<bool>,
189    managed_payments: Option<Option<stripe_shared::SmorResourceManagedPayments>>,
190    metadata: Option<std::collections::HashMap<String, String>>,
191    next_action: Option<Option<stripe_shared::PaymentIntentNextAction>>,
192    on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
193    payment_details: Option<Option<stripe_shared::PaymentFlowsPaymentDetails>>,
194    payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
195    payment_method_configuration_details:
196        Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>,
197    payment_method_options: Option<Option<stripe_shared::PaymentIntentPaymentMethodOptions>>,
198    payment_method_types: Option<Vec<String>>,
199    presentment_details: Option<Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>>,
200    processing: Option<Option<stripe_shared::PaymentIntentProcessing>>,
201    receipt_email: Option<Option<String>>,
202    review: Option<Option<stripe_types::Expandable<stripe_shared::Review>>>,
203    setup_future_usage: Option<Option<stripe_shared::PaymentIntentSetupFutureUsage>>,
204    shipping: Option<Option<stripe_shared::Shipping>>,
205    source: Option<Option<stripe_types::Expandable<stripe_shared::PaymentSource>>>,
206    statement_descriptor: Option<Option<String>>,
207    statement_descriptor_suffix: Option<Option<String>>,
208    status: Option<PaymentIntentStatus>,
209    transfer_data: Option<Option<stripe_shared::TransferData>>,
210    transfer_group: Option<Option<String>>,
211}
212
213#[allow(
214    unused_variables,
215    irrefutable_let_patterns,
216    clippy::let_unit_value,
217    clippy::match_single_binding,
218    clippy::single_match
219)]
220const _: () = {
221    use miniserde::de::{Map, Visitor};
222    use miniserde::json::Value;
223    use miniserde::{Deserialize, Result, make_place};
224    use stripe_types::miniserde_helpers::FromValueOpt;
225    use stripe_types::{MapBuilder, ObjectDeser};
226
227    make_place!(Place);
228
229    impl Deserialize for PaymentIntent {
230        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
231            Place::new(out)
232        }
233    }
234
235    struct Builder<'a> {
236        out: &'a mut Option<PaymentIntent>,
237        builder: PaymentIntentBuilder,
238    }
239
240    impl Visitor for Place<PaymentIntent> {
241        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
242            Ok(Box::new(Builder {
243                out: &mut self.out,
244                builder: PaymentIntentBuilder::deser_default(),
245            }))
246        }
247    }
248
249    impl MapBuilder for PaymentIntentBuilder {
250        type Out = PaymentIntent;
251        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
252            Ok(match k {
253                "amount" => Deserialize::begin(&mut self.amount),
254                "amount_capturable" => Deserialize::begin(&mut self.amount_capturable),
255                "amount_details" => Deserialize::begin(&mut self.amount_details),
256                "amount_received" => Deserialize::begin(&mut self.amount_received),
257                "application" => Deserialize::begin(&mut self.application),
258                "application_fee_amount" => Deserialize::begin(&mut self.application_fee_amount),
259                "automatic_payment_methods" => {
260                    Deserialize::begin(&mut self.automatic_payment_methods)
261                }
262                "canceled_at" => Deserialize::begin(&mut self.canceled_at),
263                "cancellation_reason" => Deserialize::begin(&mut self.cancellation_reason),
264                "capture_method" => Deserialize::begin(&mut self.capture_method),
265                "client_secret" => Deserialize::begin(&mut self.client_secret),
266                "confirmation_method" => Deserialize::begin(&mut self.confirmation_method),
267                "created" => Deserialize::begin(&mut self.created),
268                "currency" => Deserialize::begin(&mut self.currency),
269                "customer" => Deserialize::begin(&mut self.customer),
270                "customer_account" => Deserialize::begin(&mut self.customer_account),
271                "description" => Deserialize::begin(&mut self.description),
272                "excluded_payment_method_types" => {
273                    Deserialize::begin(&mut self.excluded_payment_method_types)
274                }
275                "hooks" => Deserialize::begin(&mut self.hooks),
276                "id" => Deserialize::begin(&mut self.id),
277                "last_payment_error" => Deserialize::begin(&mut self.last_payment_error),
278                "latest_charge" => Deserialize::begin(&mut self.latest_charge),
279                "livemode" => Deserialize::begin(&mut self.livemode),
280                "managed_payments" => Deserialize::begin(&mut self.managed_payments),
281                "metadata" => Deserialize::begin(&mut self.metadata),
282                "next_action" => Deserialize::begin(&mut self.next_action),
283                "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
284                "payment_details" => Deserialize::begin(&mut self.payment_details),
285                "payment_method" => Deserialize::begin(&mut self.payment_method),
286                "payment_method_configuration_details" => {
287                    Deserialize::begin(&mut self.payment_method_configuration_details)
288                }
289                "payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
290                "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
291                "presentment_details" => Deserialize::begin(&mut self.presentment_details),
292                "processing" => Deserialize::begin(&mut self.processing),
293                "receipt_email" => Deserialize::begin(&mut self.receipt_email),
294                "review" => Deserialize::begin(&mut self.review),
295                "setup_future_usage" => Deserialize::begin(&mut self.setup_future_usage),
296                "shipping" => Deserialize::begin(&mut self.shipping),
297                "source" => Deserialize::begin(&mut self.source),
298                "statement_descriptor" => Deserialize::begin(&mut self.statement_descriptor),
299                "statement_descriptor_suffix" => {
300                    Deserialize::begin(&mut self.statement_descriptor_suffix)
301                }
302                "status" => Deserialize::begin(&mut self.status),
303                "transfer_data" => Deserialize::begin(&mut self.transfer_data),
304                "transfer_group" => Deserialize::begin(&mut self.transfer_group),
305                _ => <dyn Visitor>::ignore(),
306            })
307        }
308
309        fn deser_default() -> Self {
310            Self {
311                amount: None,
312                amount_capturable: None,
313                amount_details: Some(None),
314                amount_received: None,
315                application: Some(None),
316                application_fee_amount: Some(None),
317                automatic_payment_methods: Some(None),
318                canceled_at: Some(None),
319                cancellation_reason: Some(None),
320                capture_method: None,
321                client_secret: Some(None),
322                confirmation_method: None,
323                created: None,
324                currency: None,
325                customer: Some(None),
326                customer_account: Some(None),
327                description: Some(None),
328                excluded_payment_method_types: Some(None),
329                hooks: Some(None),
330                id: None,
331                last_payment_error: Some(None),
332                latest_charge: Some(None),
333                livemode: None,
334                managed_payments: Some(None),
335                metadata: None,
336                next_action: Some(None),
337                on_behalf_of: Some(None),
338                payment_details: Some(None),
339                payment_method: Some(None),
340                payment_method_configuration_details: Some(None),
341                payment_method_options: Some(None),
342                payment_method_types: None,
343                presentment_details: Some(None),
344                processing: Some(None),
345                receipt_email: Some(None),
346                review: Some(None),
347                setup_future_usage: Some(None),
348                shipping: Some(None),
349                source: Some(None),
350                statement_descriptor: Some(None),
351                statement_descriptor_suffix: Some(None),
352                status: None,
353                transfer_data: Some(None),
354                transfer_group: Some(None),
355            }
356        }
357
358        fn take_out(&mut self) -> Option<Self::Out> {
359            let (
360                Some(amount),
361                Some(amount_capturable),
362                Some(amount_details),
363                Some(amount_received),
364                Some(application),
365                Some(application_fee_amount),
366                Some(automatic_payment_methods),
367                Some(canceled_at),
368                Some(cancellation_reason),
369                Some(capture_method),
370                Some(client_secret),
371                Some(confirmation_method),
372                Some(created),
373                Some(currency),
374                Some(customer),
375                Some(customer_account),
376                Some(description),
377                Some(excluded_payment_method_types),
378                Some(hooks),
379                Some(id),
380                Some(last_payment_error),
381                Some(latest_charge),
382                Some(livemode),
383                Some(managed_payments),
384                Some(metadata),
385                Some(next_action),
386                Some(on_behalf_of),
387                Some(payment_details),
388                Some(payment_method),
389                Some(payment_method_configuration_details),
390                Some(payment_method_options),
391                Some(payment_method_types),
392                Some(presentment_details),
393                Some(processing),
394                Some(receipt_email),
395                Some(review),
396                Some(setup_future_usage),
397                Some(shipping),
398                Some(source),
399                Some(statement_descriptor),
400                Some(statement_descriptor_suffix),
401                Some(status),
402                Some(transfer_data),
403                Some(transfer_group),
404            ) = (
405                self.amount,
406                self.amount_capturable,
407                self.amount_details.take(),
408                self.amount_received,
409                self.application.take(),
410                self.application_fee_amount,
411                self.automatic_payment_methods.take(),
412                self.canceled_at,
413                self.cancellation_reason.take(),
414                self.capture_method.take(),
415                self.client_secret.take(),
416                self.confirmation_method.take(),
417                self.created,
418                self.currency.take(),
419                self.customer.take(),
420                self.customer_account.take(),
421                self.description.take(),
422                self.excluded_payment_method_types.take(),
423                self.hooks.take(),
424                self.id.take(),
425                self.last_payment_error.take(),
426                self.latest_charge.take(),
427                self.livemode,
428                self.managed_payments,
429                self.metadata.take(),
430                self.next_action.take(),
431                self.on_behalf_of.take(),
432                self.payment_details.take(),
433                self.payment_method.take(),
434                self.payment_method_configuration_details.take(),
435                self.payment_method_options.take(),
436                self.payment_method_types.take(),
437                self.presentment_details.take(),
438                self.processing.take(),
439                self.receipt_email.take(),
440                self.review.take(),
441                self.setup_future_usage.take(),
442                self.shipping.take(),
443                self.source.take(),
444                self.statement_descriptor.take(),
445                self.statement_descriptor_suffix.take(),
446                self.status.take(),
447                self.transfer_data.take(),
448                self.transfer_group.take(),
449            )
450            else {
451                return None;
452            };
453            Some(Self::Out {
454                amount,
455                amount_capturable,
456                amount_details,
457                amount_received,
458                application,
459                application_fee_amount,
460                automatic_payment_methods,
461                canceled_at,
462                cancellation_reason,
463                capture_method,
464                client_secret,
465                confirmation_method,
466                created,
467                currency,
468                customer,
469                customer_account,
470                description,
471                excluded_payment_method_types,
472                hooks,
473                id,
474                last_payment_error,
475                latest_charge,
476                livemode,
477                managed_payments,
478                metadata,
479                next_action,
480                on_behalf_of,
481                payment_details,
482                payment_method,
483                payment_method_configuration_details,
484                payment_method_options,
485                payment_method_types,
486                presentment_details,
487                processing,
488                receipt_email,
489                review,
490                setup_future_usage,
491                shipping,
492                source,
493                statement_descriptor,
494                statement_descriptor_suffix,
495                status,
496                transfer_data,
497                transfer_group,
498            })
499        }
500    }
501
502    impl Map for Builder<'_> {
503        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
504            self.builder.key(k)
505        }
506
507        fn finish(&mut self) -> Result<()> {
508            *self.out = self.builder.take_out();
509            Ok(())
510        }
511    }
512
513    impl ObjectDeser for PaymentIntent {
514        type Builder = PaymentIntentBuilder;
515    }
516
517    impl FromValueOpt for PaymentIntent {
518        fn from_value(v: Value) -> Option<Self> {
519            let Value::Object(obj) = v else {
520                return None;
521            };
522            let mut b = PaymentIntentBuilder::deser_default();
523            for (k, v) in obj {
524                match k.as_str() {
525                    "amount" => b.amount = FromValueOpt::from_value(v),
526                    "amount_capturable" => b.amount_capturable = FromValueOpt::from_value(v),
527                    "amount_details" => b.amount_details = FromValueOpt::from_value(v),
528                    "amount_received" => b.amount_received = FromValueOpt::from_value(v),
529                    "application" => b.application = FromValueOpt::from_value(v),
530                    "application_fee_amount" => {
531                        b.application_fee_amount = FromValueOpt::from_value(v)
532                    }
533                    "automatic_payment_methods" => {
534                        b.automatic_payment_methods = FromValueOpt::from_value(v)
535                    }
536                    "canceled_at" => b.canceled_at = FromValueOpt::from_value(v),
537                    "cancellation_reason" => b.cancellation_reason = FromValueOpt::from_value(v),
538                    "capture_method" => b.capture_method = FromValueOpt::from_value(v),
539                    "client_secret" => b.client_secret = FromValueOpt::from_value(v),
540                    "confirmation_method" => b.confirmation_method = FromValueOpt::from_value(v),
541                    "created" => b.created = FromValueOpt::from_value(v),
542                    "currency" => b.currency = FromValueOpt::from_value(v),
543                    "customer" => b.customer = FromValueOpt::from_value(v),
544                    "customer_account" => b.customer_account = FromValueOpt::from_value(v),
545                    "description" => b.description = FromValueOpt::from_value(v),
546                    "excluded_payment_method_types" => {
547                        b.excluded_payment_method_types = FromValueOpt::from_value(v)
548                    }
549                    "hooks" => b.hooks = FromValueOpt::from_value(v),
550                    "id" => b.id = FromValueOpt::from_value(v),
551                    "last_payment_error" => b.last_payment_error = FromValueOpt::from_value(v),
552                    "latest_charge" => b.latest_charge = FromValueOpt::from_value(v),
553                    "livemode" => b.livemode = FromValueOpt::from_value(v),
554                    "managed_payments" => b.managed_payments = FromValueOpt::from_value(v),
555                    "metadata" => b.metadata = FromValueOpt::from_value(v),
556                    "next_action" => b.next_action = FromValueOpt::from_value(v),
557                    "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
558                    "payment_details" => b.payment_details = FromValueOpt::from_value(v),
559                    "payment_method" => b.payment_method = FromValueOpt::from_value(v),
560                    "payment_method_configuration_details" => {
561                        b.payment_method_configuration_details = FromValueOpt::from_value(v)
562                    }
563                    "payment_method_options" => {
564                        b.payment_method_options = FromValueOpt::from_value(v)
565                    }
566                    "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
567                    "presentment_details" => b.presentment_details = FromValueOpt::from_value(v),
568                    "processing" => b.processing = FromValueOpt::from_value(v),
569                    "receipt_email" => b.receipt_email = FromValueOpt::from_value(v),
570                    "review" => b.review = FromValueOpt::from_value(v),
571                    "setup_future_usage" => b.setup_future_usage = FromValueOpt::from_value(v),
572                    "shipping" => b.shipping = FromValueOpt::from_value(v),
573                    "source" => b.source = FromValueOpt::from_value(v),
574                    "statement_descriptor" => b.statement_descriptor = FromValueOpt::from_value(v),
575                    "statement_descriptor_suffix" => {
576                        b.statement_descriptor_suffix = FromValueOpt::from_value(v)
577                    }
578                    "status" => b.status = FromValueOpt::from_value(v),
579                    "transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
580                    "transfer_group" => b.transfer_group = FromValueOpt::from_value(v),
581                    _ => {}
582                }
583            }
584            b.take_out()
585        }
586    }
587};
588#[cfg(feature = "serialize")]
589impl serde::Serialize for PaymentIntent {
590    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
591        use serde::ser::SerializeStruct;
592        let mut s = s.serialize_struct("PaymentIntent", 45)?;
593        s.serialize_field("amount", &self.amount)?;
594        s.serialize_field("amount_capturable", &self.amount_capturable)?;
595        s.serialize_field("amount_details", &self.amount_details)?;
596        s.serialize_field("amount_received", &self.amount_received)?;
597        s.serialize_field("application", &self.application)?;
598        s.serialize_field("application_fee_amount", &self.application_fee_amount)?;
599        s.serialize_field("automatic_payment_methods", &self.automatic_payment_methods)?;
600        s.serialize_field("canceled_at", &self.canceled_at)?;
601        s.serialize_field("cancellation_reason", &self.cancellation_reason)?;
602        s.serialize_field("capture_method", &self.capture_method)?;
603        s.serialize_field("client_secret", &self.client_secret)?;
604        s.serialize_field("confirmation_method", &self.confirmation_method)?;
605        s.serialize_field("created", &self.created)?;
606        s.serialize_field("currency", &self.currency)?;
607        s.serialize_field("customer", &self.customer)?;
608        s.serialize_field("customer_account", &self.customer_account)?;
609        s.serialize_field("description", &self.description)?;
610        s.serialize_field("excluded_payment_method_types", &self.excluded_payment_method_types)?;
611        s.serialize_field("hooks", &self.hooks)?;
612        s.serialize_field("id", &self.id)?;
613        s.serialize_field("last_payment_error", &self.last_payment_error)?;
614        s.serialize_field("latest_charge", &self.latest_charge)?;
615        s.serialize_field("livemode", &self.livemode)?;
616        s.serialize_field("managed_payments", &self.managed_payments)?;
617        s.serialize_field("metadata", &self.metadata)?;
618        s.serialize_field("next_action", &self.next_action)?;
619        s.serialize_field("on_behalf_of", &self.on_behalf_of)?;
620        s.serialize_field("payment_details", &self.payment_details)?;
621        s.serialize_field("payment_method", &self.payment_method)?;
622        s.serialize_field(
623            "payment_method_configuration_details",
624            &self.payment_method_configuration_details,
625        )?;
626        s.serialize_field("payment_method_options", &self.payment_method_options)?;
627        s.serialize_field("payment_method_types", &self.payment_method_types)?;
628        s.serialize_field("presentment_details", &self.presentment_details)?;
629        s.serialize_field("processing", &self.processing)?;
630        s.serialize_field("receipt_email", &self.receipt_email)?;
631        s.serialize_field("review", &self.review)?;
632        s.serialize_field("setup_future_usage", &self.setup_future_usage)?;
633        s.serialize_field("shipping", &self.shipping)?;
634        s.serialize_field("source", &self.source)?;
635        s.serialize_field("statement_descriptor", &self.statement_descriptor)?;
636        s.serialize_field("statement_descriptor_suffix", &self.statement_descriptor_suffix)?;
637        s.serialize_field("status", &self.status)?;
638        s.serialize_field("transfer_data", &self.transfer_data)?;
639        s.serialize_field("transfer_group", &self.transfer_group)?;
640
641        s.serialize_field("object", "payment_intent")?;
642        s.end()
643    }
644}
645/// Reason for cancellation of this PaymentIntent, either user-provided (`duplicate`, `fraudulent`, `requested_by_customer`, or `abandoned`) or generated by Stripe internally (`failed_invoice`, `void_invoice`, `automatic`, or `expired`).
646#[derive(Clone, Eq, PartialEq)]
647#[non_exhaustive]
648pub enum PaymentIntentCancellationReason {
649    Abandoned,
650    Automatic,
651    Duplicate,
652    Expired,
653    FailedInvoice,
654    Fraudulent,
655    RequestedByCustomer,
656    VoidInvoice,
657    /// An unrecognized value from Stripe. Should not be used as a request parameter.
658    Unknown(String),
659}
660impl PaymentIntentCancellationReason {
661    pub fn as_str(&self) -> &str {
662        use PaymentIntentCancellationReason::*;
663        match self {
664            Abandoned => "abandoned",
665            Automatic => "automatic",
666            Duplicate => "duplicate",
667            Expired => "expired",
668            FailedInvoice => "failed_invoice",
669            Fraudulent => "fraudulent",
670            RequestedByCustomer => "requested_by_customer",
671            VoidInvoice => "void_invoice",
672            Unknown(v) => v,
673        }
674    }
675}
676
677impl std::str::FromStr for PaymentIntentCancellationReason {
678    type Err = std::convert::Infallible;
679    fn from_str(s: &str) -> Result<Self, Self::Err> {
680        use PaymentIntentCancellationReason::*;
681        match s {
682            "abandoned" => Ok(Abandoned),
683            "automatic" => Ok(Automatic),
684            "duplicate" => Ok(Duplicate),
685            "expired" => Ok(Expired),
686            "failed_invoice" => Ok(FailedInvoice),
687            "fraudulent" => Ok(Fraudulent),
688            "requested_by_customer" => Ok(RequestedByCustomer),
689            "void_invoice" => Ok(VoidInvoice),
690            v => {
691                tracing::warn!(
692                    "Unknown value '{}' for enum '{}'",
693                    v,
694                    "PaymentIntentCancellationReason"
695                );
696                Ok(Unknown(v.to_owned()))
697            }
698        }
699    }
700}
701impl std::fmt::Display for PaymentIntentCancellationReason {
702    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
703        f.write_str(self.as_str())
704    }
705}
706
707#[cfg(not(feature = "redact-generated-debug"))]
708impl std::fmt::Debug for PaymentIntentCancellationReason {
709    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
710        f.write_str(self.as_str())
711    }
712}
713#[cfg(feature = "redact-generated-debug")]
714impl std::fmt::Debug for PaymentIntentCancellationReason {
715    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
716        f.debug_struct(stringify!(PaymentIntentCancellationReason)).finish_non_exhaustive()
717    }
718}
719#[cfg(feature = "serialize")]
720impl serde::Serialize for PaymentIntentCancellationReason {
721    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
722    where
723        S: serde::Serializer,
724    {
725        serializer.serialize_str(self.as_str())
726    }
727}
728impl miniserde::Deserialize for PaymentIntentCancellationReason {
729    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
730        crate::Place::new(out)
731    }
732}
733
734impl miniserde::de::Visitor for crate::Place<PaymentIntentCancellationReason> {
735    fn string(&mut self, s: &str) -> miniserde::Result<()> {
736        use std::str::FromStr;
737        self.out = Some(PaymentIntentCancellationReason::from_str(s).expect("infallible"));
738        Ok(())
739    }
740}
741
742stripe_types::impl_from_val_with_from_str!(PaymentIntentCancellationReason);
743#[cfg(feature = "deserialize")]
744impl<'de> serde::Deserialize<'de> for PaymentIntentCancellationReason {
745    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
746        use std::str::FromStr;
747        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
748        Ok(Self::from_str(&s).expect("infallible"))
749    }
750}
751/// Status of this PaymentIntent, one of `requires_payment_method`, `requires_confirmation`, `requires_action`, `processing`, `requires_capture`, `canceled`, or `succeeded`.
752/// Read more about each PaymentIntent [status](https://docs.stripe.com/payments/intents#intent-statuses).
753#[derive(Clone, Eq, PartialEq)]
754#[non_exhaustive]
755pub enum PaymentIntentStatus {
756    Canceled,
757    Processing,
758    RequiresAction,
759    RequiresCapture,
760    RequiresConfirmation,
761    RequiresPaymentMethod,
762    Succeeded,
763    /// An unrecognized value from Stripe. Should not be used as a request parameter.
764    Unknown(String),
765}
766impl PaymentIntentStatus {
767    pub fn as_str(&self) -> &str {
768        use PaymentIntentStatus::*;
769        match self {
770            Canceled => "canceled",
771            Processing => "processing",
772            RequiresAction => "requires_action",
773            RequiresCapture => "requires_capture",
774            RequiresConfirmation => "requires_confirmation",
775            RequiresPaymentMethod => "requires_payment_method",
776            Succeeded => "succeeded",
777            Unknown(v) => v,
778        }
779    }
780}
781
782impl std::str::FromStr for PaymentIntentStatus {
783    type Err = std::convert::Infallible;
784    fn from_str(s: &str) -> Result<Self, Self::Err> {
785        use PaymentIntentStatus::*;
786        match s {
787            "canceled" => Ok(Canceled),
788            "processing" => Ok(Processing),
789            "requires_action" => Ok(RequiresAction),
790            "requires_capture" => Ok(RequiresCapture),
791            "requires_confirmation" => Ok(RequiresConfirmation),
792            "requires_payment_method" => Ok(RequiresPaymentMethod),
793            "succeeded" => Ok(Succeeded),
794            v => {
795                tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentIntentStatus");
796                Ok(Unknown(v.to_owned()))
797            }
798        }
799    }
800}
801impl std::fmt::Display for PaymentIntentStatus {
802    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
803        f.write_str(self.as_str())
804    }
805}
806
807#[cfg(not(feature = "redact-generated-debug"))]
808impl std::fmt::Debug for PaymentIntentStatus {
809    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
810        f.write_str(self.as_str())
811    }
812}
813#[cfg(feature = "redact-generated-debug")]
814impl std::fmt::Debug for PaymentIntentStatus {
815    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
816        f.debug_struct(stringify!(PaymentIntentStatus)).finish_non_exhaustive()
817    }
818}
819#[cfg(feature = "serialize")]
820impl serde::Serialize for PaymentIntentStatus {
821    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
822    where
823        S: serde::Serializer,
824    {
825        serializer.serialize_str(self.as_str())
826    }
827}
828impl miniserde::Deserialize for PaymentIntentStatus {
829    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
830        crate::Place::new(out)
831    }
832}
833
834impl miniserde::de::Visitor for crate::Place<PaymentIntentStatus> {
835    fn string(&mut self, s: &str) -> miniserde::Result<()> {
836        use std::str::FromStr;
837        self.out = Some(PaymentIntentStatus::from_str(s).expect("infallible"));
838        Ok(())
839    }
840}
841
842stripe_types::impl_from_val_with_from_str!(PaymentIntentStatus);
843#[cfg(feature = "deserialize")]
844impl<'de> serde::Deserialize<'de> for PaymentIntentStatus {
845    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
846        use std::str::FromStr;
847        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
848        Ok(Self::from_str(&s).expect("infallible"))
849    }
850}
851impl stripe_types::Object for PaymentIntent {
852    type Id = stripe_shared::PaymentIntentId;
853    fn id(&self) -> &Self::Id {
854        &self.id
855    }
856
857    fn into_id(self) -> Self::Id {
858        self.id
859    }
860}
861stripe_types::def_id!(PaymentIntentId);
862#[derive(Clone, Eq, PartialEq)]
863#[non_exhaustive]
864pub enum PaymentIntentCaptureMethod {
865    Automatic,
866    AutomaticAsync,
867    Manual,
868    /// An unrecognized value from Stripe. Should not be used as a request parameter.
869    Unknown(String),
870}
871impl PaymentIntentCaptureMethod {
872    pub fn as_str(&self) -> &str {
873        use PaymentIntentCaptureMethod::*;
874        match self {
875            Automatic => "automatic",
876            AutomaticAsync => "automatic_async",
877            Manual => "manual",
878            Unknown(v) => v,
879        }
880    }
881}
882
883impl std::str::FromStr for PaymentIntentCaptureMethod {
884    type Err = std::convert::Infallible;
885    fn from_str(s: &str) -> Result<Self, Self::Err> {
886        use PaymentIntentCaptureMethod::*;
887        match s {
888            "automatic" => Ok(Automatic),
889            "automatic_async" => Ok(AutomaticAsync),
890            "manual" => Ok(Manual),
891            v => {
892                tracing::warn!("Unknown value '{}' for enum '{}'", v, "PaymentIntentCaptureMethod");
893                Ok(Unknown(v.to_owned()))
894            }
895        }
896    }
897}
898impl std::fmt::Display for PaymentIntentCaptureMethod {
899    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
900        f.write_str(self.as_str())
901    }
902}
903
904#[cfg(not(feature = "redact-generated-debug"))]
905impl std::fmt::Debug for PaymentIntentCaptureMethod {
906    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
907        f.write_str(self.as_str())
908    }
909}
910#[cfg(feature = "redact-generated-debug")]
911impl std::fmt::Debug for PaymentIntentCaptureMethod {
912    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
913        f.debug_struct(stringify!(PaymentIntentCaptureMethod)).finish_non_exhaustive()
914    }
915}
916impl serde::Serialize for PaymentIntentCaptureMethod {
917    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
918    where
919        S: serde::Serializer,
920    {
921        serializer.serialize_str(self.as_str())
922    }
923}
924impl miniserde::Deserialize for PaymentIntentCaptureMethod {
925    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
926        crate::Place::new(out)
927    }
928}
929
930impl miniserde::de::Visitor for crate::Place<PaymentIntentCaptureMethod> {
931    fn string(&mut self, s: &str) -> miniserde::Result<()> {
932        use std::str::FromStr;
933        self.out = Some(PaymentIntentCaptureMethod::from_str(s).expect("infallible"));
934        Ok(())
935    }
936}
937
938stripe_types::impl_from_val_with_from_str!(PaymentIntentCaptureMethod);
939#[cfg(feature = "deserialize")]
940impl<'de> serde::Deserialize<'de> for PaymentIntentCaptureMethod {
941    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
942        use std::str::FromStr;
943        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
944        Ok(Self::from_str(&s).expect("infallible"))
945    }
946}
947#[derive(Clone, Eq, PartialEq)]
948#[non_exhaustive]
949pub enum PaymentIntentConfirmationMethod {
950    Automatic,
951    Manual,
952    /// An unrecognized value from Stripe. Should not be used as a request parameter.
953    Unknown(String),
954}
955impl PaymentIntentConfirmationMethod {
956    pub fn as_str(&self) -> &str {
957        use PaymentIntentConfirmationMethod::*;
958        match self {
959            Automatic => "automatic",
960            Manual => "manual",
961            Unknown(v) => v,
962        }
963    }
964}
965
966impl std::str::FromStr for PaymentIntentConfirmationMethod {
967    type Err = std::convert::Infallible;
968    fn from_str(s: &str) -> Result<Self, Self::Err> {
969        use PaymentIntentConfirmationMethod::*;
970        match s {
971            "automatic" => Ok(Automatic),
972            "manual" => Ok(Manual),
973            v => {
974                tracing::warn!(
975                    "Unknown value '{}' for enum '{}'",
976                    v,
977                    "PaymentIntentConfirmationMethod"
978                );
979                Ok(Unknown(v.to_owned()))
980            }
981        }
982    }
983}
984impl std::fmt::Display for PaymentIntentConfirmationMethod {
985    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
986        f.write_str(self.as_str())
987    }
988}
989
990#[cfg(not(feature = "redact-generated-debug"))]
991impl std::fmt::Debug for PaymentIntentConfirmationMethod {
992    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
993        f.write_str(self.as_str())
994    }
995}
996#[cfg(feature = "redact-generated-debug")]
997impl std::fmt::Debug for PaymentIntentConfirmationMethod {
998    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
999        f.debug_struct(stringify!(PaymentIntentConfirmationMethod)).finish_non_exhaustive()
1000    }
1001}
1002impl serde::Serialize for PaymentIntentConfirmationMethod {
1003    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1004    where
1005        S: serde::Serializer,
1006    {
1007        serializer.serialize_str(self.as_str())
1008    }
1009}
1010impl miniserde::Deserialize for PaymentIntentConfirmationMethod {
1011    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1012        crate::Place::new(out)
1013    }
1014}
1015
1016impl miniserde::de::Visitor for crate::Place<PaymentIntentConfirmationMethod> {
1017    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1018        use std::str::FromStr;
1019        self.out = Some(PaymentIntentConfirmationMethod::from_str(s).expect("infallible"));
1020        Ok(())
1021    }
1022}
1023
1024stripe_types::impl_from_val_with_from_str!(PaymentIntentConfirmationMethod);
1025#[cfg(feature = "deserialize")]
1026impl<'de> serde::Deserialize<'de> for PaymentIntentConfirmationMethod {
1027    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1028        use std::str::FromStr;
1029        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1030        Ok(Self::from_str(&s).expect("infallible"))
1031    }
1032}
1033#[derive(Clone, Eq, PartialEq)]
1034#[non_exhaustive]
1035pub enum PaymentIntentExcludedPaymentMethodTypes {
1036    AcssDebit,
1037    Affirm,
1038    AfterpayClearpay,
1039    Alipay,
1040    Alma,
1041    AmazonPay,
1042    AuBecsDebit,
1043    BacsDebit,
1044    Bancontact,
1045    Billie,
1046    Blik,
1047    Boleto,
1048    Card,
1049    Cashapp,
1050    Crypto,
1051    CustomerBalance,
1052    Eps,
1053    Fpx,
1054    Giropay,
1055    Grabpay,
1056    Ideal,
1057    KakaoPay,
1058    Klarna,
1059    Konbini,
1060    KrCard,
1061    MbWay,
1062    Mobilepay,
1063    Multibanco,
1064    NaverPay,
1065    NzBankAccount,
1066    Oxxo,
1067    P24,
1068    PayByBank,
1069    Payco,
1070    Paynow,
1071    Paypal,
1072    Payto,
1073    Pix,
1074    Promptpay,
1075    RevolutPay,
1076    SamsungPay,
1077    Satispay,
1078    SepaDebit,
1079    Sofort,
1080    Sunbit,
1081    Swish,
1082    Twint,
1083    Upi,
1084    UsBankAccount,
1085    WechatPay,
1086    Zip,
1087    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1088    Unknown(String),
1089}
1090impl PaymentIntentExcludedPaymentMethodTypes {
1091    pub fn as_str(&self) -> &str {
1092        use PaymentIntentExcludedPaymentMethodTypes::*;
1093        match self {
1094            AcssDebit => "acss_debit",
1095            Affirm => "affirm",
1096            AfterpayClearpay => "afterpay_clearpay",
1097            Alipay => "alipay",
1098            Alma => "alma",
1099            AmazonPay => "amazon_pay",
1100            AuBecsDebit => "au_becs_debit",
1101            BacsDebit => "bacs_debit",
1102            Bancontact => "bancontact",
1103            Billie => "billie",
1104            Blik => "blik",
1105            Boleto => "boleto",
1106            Card => "card",
1107            Cashapp => "cashapp",
1108            Crypto => "crypto",
1109            CustomerBalance => "customer_balance",
1110            Eps => "eps",
1111            Fpx => "fpx",
1112            Giropay => "giropay",
1113            Grabpay => "grabpay",
1114            Ideal => "ideal",
1115            KakaoPay => "kakao_pay",
1116            Klarna => "klarna",
1117            Konbini => "konbini",
1118            KrCard => "kr_card",
1119            MbWay => "mb_way",
1120            Mobilepay => "mobilepay",
1121            Multibanco => "multibanco",
1122            NaverPay => "naver_pay",
1123            NzBankAccount => "nz_bank_account",
1124            Oxxo => "oxxo",
1125            P24 => "p24",
1126            PayByBank => "pay_by_bank",
1127            Payco => "payco",
1128            Paynow => "paynow",
1129            Paypal => "paypal",
1130            Payto => "payto",
1131            Pix => "pix",
1132            Promptpay => "promptpay",
1133            RevolutPay => "revolut_pay",
1134            SamsungPay => "samsung_pay",
1135            Satispay => "satispay",
1136            SepaDebit => "sepa_debit",
1137            Sofort => "sofort",
1138            Sunbit => "sunbit",
1139            Swish => "swish",
1140            Twint => "twint",
1141            Upi => "upi",
1142            UsBankAccount => "us_bank_account",
1143            WechatPay => "wechat_pay",
1144            Zip => "zip",
1145            Unknown(v) => v,
1146        }
1147    }
1148}
1149
1150impl std::str::FromStr for PaymentIntentExcludedPaymentMethodTypes {
1151    type Err = std::convert::Infallible;
1152    fn from_str(s: &str) -> Result<Self, Self::Err> {
1153        use PaymentIntentExcludedPaymentMethodTypes::*;
1154        match s {
1155            "acss_debit" => Ok(AcssDebit),
1156            "affirm" => Ok(Affirm),
1157            "afterpay_clearpay" => Ok(AfterpayClearpay),
1158            "alipay" => Ok(Alipay),
1159            "alma" => Ok(Alma),
1160            "amazon_pay" => Ok(AmazonPay),
1161            "au_becs_debit" => Ok(AuBecsDebit),
1162            "bacs_debit" => Ok(BacsDebit),
1163            "bancontact" => Ok(Bancontact),
1164            "billie" => Ok(Billie),
1165            "blik" => Ok(Blik),
1166            "boleto" => Ok(Boleto),
1167            "card" => Ok(Card),
1168            "cashapp" => Ok(Cashapp),
1169            "crypto" => Ok(Crypto),
1170            "customer_balance" => Ok(CustomerBalance),
1171            "eps" => Ok(Eps),
1172            "fpx" => Ok(Fpx),
1173            "giropay" => Ok(Giropay),
1174            "grabpay" => Ok(Grabpay),
1175            "ideal" => Ok(Ideal),
1176            "kakao_pay" => Ok(KakaoPay),
1177            "klarna" => Ok(Klarna),
1178            "konbini" => Ok(Konbini),
1179            "kr_card" => Ok(KrCard),
1180            "mb_way" => Ok(MbWay),
1181            "mobilepay" => Ok(Mobilepay),
1182            "multibanco" => Ok(Multibanco),
1183            "naver_pay" => Ok(NaverPay),
1184            "nz_bank_account" => Ok(NzBankAccount),
1185            "oxxo" => Ok(Oxxo),
1186            "p24" => Ok(P24),
1187            "pay_by_bank" => Ok(PayByBank),
1188            "payco" => Ok(Payco),
1189            "paynow" => Ok(Paynow),
1190            "paypal" => Ok(Paypal),
1191            "payto" => Ok(Payto),
1192            "pix" => Ok(Pix),
1193            "promptpay" => Ok(Promptpay),
1194            "revolut_pay" => Ok(RevolutPay),
1195            "samsung_pay" => Ok(SamsungPay),
1196            "satispay" => Ok(Satispay),
1197            "sepa_debit" => Ok(SepaDebit),
1198            "sofort" => Ok(Sofort),
1199            "sunbit" => Ok(Sunbit),
1200            "swish" => Ok(Swish),
1201            "twint" => Ok(Twint),
1202            "upi" => Ok(Upi),
1203            "us_bank_account" => Ok(UsBankAccount),
1204            "wechat_pay" => Ok(WechatPay),
1205            "zip" => Ok(Zip),
1206            v => {
1207                tracing::warn!(
1208                    "Unknown value '{}' for enum '{}'",
1209                    v,
1210                    "PaymentIntentExcludedPaymentMethodTypes"
1211                );
1212                Ok(Unknown(v.to_owned()))
1213            }
1214        }
1215    }
1216}
1217impl std::fmt::Display for PaymentIntentExcludedPaymentMethodTypes {
1218    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1219        f.write_str(self.as_str())
1220    }
1221}
1222
1223#[cfg(not(feature = "redact-generated-debug"))]
1224impl std::fmt::Debug for PaymentIntentExcludedPaymentMethodTypes {
1225    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1226        f.write_str(self.as_str())
1227    }
1228}
1229#[cfg(feature = "redact-generated-debug")]
1230impl std::fmt::Debug for PaymentIntentExcludedPaymentMethodTypes {
1231    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1232        f.debug_struct(stringify!(PaymentIntentExcludedPaymentMethodTypes)).finish_non_exhaustive()
1233    }
1234}
1235impl serde::Serialize for PaymentIntentExcludedPaymentMethodTypes {
1236    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1237    where
1238        S: serde::Serializer,
1239    {
1240        serializer.serialize_str(self.as_str())
1241    }
1242}
1243impl miniserde::Deserialize for PaymentIntentExcludedPaymentMethodTypes {
1244    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1245        crate::Place::new(out)
1246    }
1247}
1248
1249impl miniserde::de::Visitor for crate::Place<PaymentIntentExcludedPaymentMethodTypes> {
1250    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1251        use std::str::FromStr;
1252        self.out = Some(PaymentIntentExcludedPaymentMethodTypes::from_str(s).expect("infallible"));
1253        Ok(())
1254    }
1255}
1256
1257stripe_types::impl_from_val_with_from_str!(PaymentIntentExcludedPaymentMethodTypes);
1258#[cfg(feature = "deserialize")]
1259impl<'de> serde::Deserialize<'de> for PaymentIntentExcludedPaymentMethodTypes {
1260    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1261        use std::str::FromStr;
1262        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1263        Ok(Self::from_str(&s).expect("infallible"))
1264    }
1265}
1266#[derive(Clone, Eq, PartialEq)]
1267#[non_exhaustive]
1268pub enum PaymentIntentSetupFutureUsage {
1269    OffSession,
1270    OnSession,
1271    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1272    Unknown(String),
1273}
1274impl PaymentIntentSetupFutureUsage {
1275    pub fn as_str(&self) -> &str {
1276        use PaymentIntentSetupFutureUsage::*;
1277        match self {
1278            OffSession => "off_session",
1279            OnSession => "on_session",
1280            Unknown(v) => v,
1281        }
1282    }
1283}
1284
1285impl std::str::FromStr for PaymentIntentSetupFutureUsage {
1286    type Err = std::convert::Infallible;
1287    fn from_str(s: &str) -> Result<Self, Self::Err> {
1288        use PaymentIntentSetupFutureUsage::*;
1289        match s {
1290            "off_session" => Ok(OffSession),
1291            "on_session" => Ok(OnSession),
1292            v => {
1293                tracing::warn!(
1294                    "Unknown value '{}' for enum '{}'",
1295                    v,
1296                    "PaymentIntentSetupFutureUsage"
1297                );
1298                Ok(Unknown(v.to_owned()))
1299            }
1300        }
1301    }
1302}
1303impl std::fmt::Display for PaymentIntentSetupFutureUsage {
1304    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1305        f.write_str(self.as_str())
1306    }
1307}
1308
1309#[cfg(not(feature = "redact-generated-debug"))]
1310impl std::fmt::Debug for PaymentIntentSetupFutureUsage {
1311    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1312        f.write_str(self.as_str())
1313    }
1314}
1315#[cfg(feature = "redact-generated-debug")]
1316impl std::fmt::Debug for PaymentIntentSetupFutureUsage {
1317    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1318        f.debug_struct(stringify!(PaymentIntentSetupFutureUsage)).finish_non_exhaustive()
1319    }
1320}
1321impl serde::Serialize for PaymentIntentSetupFutureUsage {
1322    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1323    where
1324        S: serde::Serializer,
1325    {
1326        serializer.serialize_str(self.as_str())
1327    }
1328}
1329impl miniserde::Deserialize for PaymentIntentSetupFutureUsage {
1330    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1331        crate::Place::new(out)
1332    }
1333}
1334
1335impl miniserde::de::Visitor for crate::Place<PaymentIntentSetupFutureUsage> {
1336    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1337        use std::str::FromStr;
1338        self.out = Some(PaymentIntentSetupFutureUsage::from_str(s).expect("infallible"));
1339        Ok(())
1340    }
1341}
1342
1343stripe_types::impl_from_val_with_from_str!(PaymentIntentSetupFutureUsage);
1344#[cfg(feature = "deserialize")]
1345impl<'de> serde::Deserialize<'de> for PaymentIntentSetupFutureUsage {
1346    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1347        use std::str::FromStr;
1348        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1349        Ok(Self::from_str(&s).expect("infallible"))
1350    }
1351}