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