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