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