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