stripe_shared/
checkout_session.rs

1/// A Checkout Session represents your customer's session as they pay for
2/// one-time purchases or subscriptions through [Checkout](https://stripe.com/docs/payments/checkout)
3/// or [Payment Links](https://stripe.com/docs/payments/payment-links). We recommend creating a
4/// new Session each time your customer attempts to pay.
5///
6/// Once payment is successful, the Checkout Session will contain a reference
7/// to the [Customer](https://stripe.com/docs/api/customers), and either the successful
8/// [PaymentIntent](https://stripe.com/docs/api/payment_intents) or an active
9/// [Subscription](https://stripe.com/docs/api/subscriptions).
10///
11/// You can create a Checkout Session on your server and redirect to its URL
12/// to begin Checkout.
13///
14/// Related guide: [Checkout quickstart](https://stripe.com/docs/checkout/quickstart)
15///
16/// For more details see <<https://stripe.com/docs/api/checkout/sessions/object>>.
17#[derive(Clone, Debug)]
18#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
19pub struct CheckoutSession {
20    /// Settings for price localization with [Adaptive Pricing](https://docs.stripe.com/payments/checkout/adaptive-pricing).
21    pub adaptive_pricing: Option<stripe_shared::PaymentPagesCheckoutSessionAdaptivePricing>,
22    /// When set, provides configuration for actions to take if this Checkout Session expires.
23    pub after_expiration: Option<stripe_shared::PaymentPagesCheckoutSessionAfterExpiration>,
24    /// Enables user redeemable promotion codes.
25    pub allow_promotion_codes: Option<bool>,
26    /// Total of all items before discounts or taxes are applied.
27    pub amount_subtotal: Option<i64>,
28    /// Total of all items after discounts and taxes are applied.
29    pub amount_total: Option<i64>,
30    pub automatic_tax: stripe_shared::PaymentPagesCheckoutSessionAutomaticTax,
31    /// Describes whether Checkout should collect the customer's billing address. Defaults to `auto`.
32    pub billing_address_collection: Option<stripe_shared::CheckoutSessionBillingAddressCollection>,
33    /// If set, Checkout displays a back button and customers will be directed to this URL if they decide to cancel payment and return to your website.
34    pub cancel_url: Option<String>,
35    /// A unique string to reference the Checkout Session. This can be a
36    /// customer ID, a cart ID, or similar, and can be used to reconcile the
37    /// Session with your internal systems.
38    pub client_reference_id: Option<String>,
39    /// The client secret of your Checkout Session.
40    /// Applies to Checkout Sessions with `ui_mode: embedded` or `ui_mode: custom`.
41    /// For `ui_mode: embedded`, the client secret is to be used when initializing Stripe.js embedded checkout.
42    /// For `ui_mode: custom`, use the client secret with [initCheckout](https://stripe.com/docs/js/custom_checkout/init) on your front end.
43    pub client_secret: Option<String>,
44    /// Information about the customer collected within the Checkout Session.
45    pub collected_information:
46        Option<stripe_shared::PaymentPagesCheckoutSessionCollectedInformation>,
47    /// Results of `consent_collection` for this session.
48    pub consent: Option<stripe_shared::PaymentPagesCheckoutSessionConsent>,
49    /// When set, provides configuration for the Checkout Session to gather active consent from customers.
50    pub consent_collection: Option<stripe_shared::PaymentPagesCheckoutSessionConsentCollection>,
51    /// Time at which the object was created. Measured in seconds since the Unix epoch.
52    pub created: stripe_types::Timestamp,
53    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
54    /// Must be a [supported currency](https://stripe.com/docs/currencies).
55    pub currency: Option<stripe_types::Currency>,
56    /// Currency conversion details for [Adaptive Pricing](https://docs.stripe.com/payments/checkout/adaptive-pricing) sessions created before 2025-03-31.
57    pub currency_conversion: Option<stripe_shared::PaymentPagesCheckoutSessionCurrencyConversion>,
58    /// Collect additional information from your customer using custom fields.
59    /// Up to 3 fields are supported.
60    pub custom_fields: Vec<stripe_shared::PaymentPagesCheckoutSessionCustomFields>,
61    pub custom_text: stripe_shared::PaymentPagesCheckoutSessionCustomText,
62    /// The ID of the customer for this Session.
63    /// For Checkout Sessions in `subscription` mode or Checkout Sessions with `customer_creation` set as `always` in `payment` mode, Checkout.
64    /// will create a new customer object based on information provided
65    /// during the payment flow unless an existing customer was provided when
66    /// the Session was created.
67    pub customer: Option<stripe_types::Expandable<stripe_shared::Customer>>,
68    /// Configure whether a Checkout Session creates a Customer when the Checkout Session completes.
69    pub customer_creation: Option<CheckoutSessionCustomerCreation>,
70    /// The customer details including the customer's tax exempt status and the customer's tax IDs.
71    /// Customer's address details are not present on Sessions in `setup` mode.
72    pub customer_details: Option<stripe_shared::PaymentPagesCheckoutSessionCustomerDetails>,
73    /// If provided, this value will be used when the Customer object is created.
74    /// If not provided, customers will be asked to enter their email address.
75    /// Use this parameter to prefill customer data if you already have an email
76    /// on file. To access information about the customer once the payment flow is
77    /// complete, use the `customer` attribute.
78    pub customer_email: Option<String>,
79    /// List of coupons and promotion codes attached to the Checkout Session.
80    pub discounts: Option<Vec<stripe_shared::PaymentPagesCheckoutSessionDiscount>>,
81    /// The timestamp at which the Checkout Session will expire.
82    pub expires_at: stripe_types::Timestamp,
83    /// Unique identifier for the object.
84    pub id: stripe_shared::CheckoutSessionId,
85    /// ID of the invoice created by the Checkout Session, if it exists.
86    pub invoice: Option<stripe_types::Expandable<stripe_shared::Invoice>>,
87    /// Details on the state of invoice creation for the Checkout Session.
88    pub invoice_creation: Option<stripe_shared::PaymentPagesCheckoutSessionInvoiceCreation>,
89    /// The line items purchased by the customer.
90    pub line_items: Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>,
91    /// Has the value `true` if the object exists in live mode or the value `false` if the object exists in test mode.
92    pub livemode: bool,
93    /// The IETF language tag of the locale Checkout is displayed in.
94    /// If blank or `auto`, the browser's locale is used.
95    pub locale: Option<stripe_shared::CheckoutSessionLocale>,
96    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
97    /// This can be useful for storing additional information about the object in a structured format.
98    pub metadata: Option<std::collections::HashMap<String, String>>,
99    /// The mode of the Checkout Session.
100    pub mode: stripe_shared::CheckoutSessionMode,
101    /// The optional items presented to the customer at checkout.
102    pub optional_items: Option<Vec<stripe_shared::PaymentPagesCheckoutSessionOptionalItem>>,
103    /// The ID of the PaymentIntent for Checkout Sessions in `payment` mode.
104    /// You can't confirm or cancel the PaymentIntent for a Checkout Session.
105    /// To cancel, [expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead.
106    pub payment_intent: Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>,
107    /// The ID of the Payment Link that created this Session.
108    pub payment_link: Option<stripe_types::Expandable<stripe_shared::PaymentLink>>,
109    /// Configure whether a Checkout Session should collect a payment method. Defaults to `always`.
110    pub payment_method_collection: Option<CheckoutSessionPaymentMethodCollection>,
111    /// Information about the payment method configuration used for this Checkout session if using dynamic payment methods.
112    pub payment_method_configuration_details:
113        Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>,
114    /// Payment-method-specific configuration for the PaymentIntent or SetupIntent of this CheckoutSession.
115    pub payment_method_options: Option<stripe_shared::CheckoutSessionPaymentMethodOptions>,
116    /// A list of the types of payment methods (e.g. card) this Checkout
117    /// Session is allowed to accept.
118    pub payment_method_types: Vec<String>,
119    /// The payment status of the Checkout Session, one of `paid`, `unpaid`, or `no_payment_required`.
120    /// You can use this value to decide when to fulfill your customer's order.
121    pub payment_status: CheckoutSessionPaymentStatus,
122    /// This property is used to set up permissions for various actions (e.g., update) on the CheckoutSession object.
123    ///
124    /// For specific permissions, please refer to their dedicated subsections, such as `permissions.update_shipping_details`.
125    pub permissions: Option<stripe_shared::PaymentPagesCheckoutSessionPermissions>,
126    pub phone_number_collection:
127        Option<stripe_shared::PaymentPagesCheckoutSessionPhoneNumberCollection>,
128    pub presentment_details: Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>,
129    /// The ID of the original expired Checkout Session that triggered the recovery flow.
130    pub recovered_from: Option<String>,
131    /// This parameter applies to `ui_mode: embedded`.
132    /// Learn more about the [redirect behavior](https://stripe.com/docs/payments/checkout/custom-success-page?payment-ui=embedded-form) of embedded sessions.
133    /// Defaults to `always`.
134    pub redirect_on_completion: Option<stripe_shared::CheckoutSessionRedirectOnCompletion>,
135    /// Applies to Checkout Sessions with `ui_mode: embedded` or `ui_mode: custom`.
136    /// The URL to redirect your customer back to after they authenticate or cancel their payment on the payment method's app or site.
137    pub return_url: Option<String>,
138    /// Controls saved payment method settings for the session.
139    /// Only available in `payment` and `subscription` mode.
140    pub saved_payment_method_options:
141        Option<stripe_shared::PaymentPagesCheckoutSessionSavedPaymentMethodOptions>,
142    /// The ID of the SetupIntent for Checkout Sessions in `setup` mode.
143    /// You can't confirm or cancel the SetupIntent for a Checkout Session.
144    /// To cancel, [expire the Checkout Session](https://stripe.com/docs/api/checkout/sessions/expire) instead.
145    pub setup_intent: Option<stripe_types::Expandable<stripe_shared::SetupIntent>>,
146    /// When set, provides configuration for Checkout to collect a shipping address from a customer.
147    pub shipping_address_collection:
148        Option<stripe_shared::PaymentPagesCheckoutSessionShippingAddressCollection>,
149    /// The details of the customer cost of shipping, including the customer chosen ShippingRate.
150    pub shipping_cost: Option<stripe_shared::PaymentPagesCheckoutSessionShippingCost>,
151    /// The shipping rate options applied to this Session.
152    pub shipping_options: Vec<stripe_shared::PaymentPagesCheckoutSessionShippingOption>,
153    /// The status of the Checkout Session, one of `open`, `complete`, or `expired`.
154    pub status: Option<stripe_shared::CheckoutSessionStatus>,
155    /// Describes the type of transaction being performed by Checkout in order to customize
156    /// relevant text on the page, such as the submit button. `submit_type` can only be
157    /// specified on Checkout Sessions in `payment` mode. If blank or `auto`, `pay` is used.
158    pub submit_type: Option<stripe_shared::CheckoutSessionSubmitType>,
159    /// The ID of the subscription for Checkout Sessions in `subscription` mode.
160    pub subscription: Option<stripe_types::Expandable<stripe_shared::Subscription>>,
161    /// The URL the customer will be directed to after the payment or
162    /// subscription creation is successful.
163    pub success_url: Option<String>,
164    pub tax_id_collection: Option<stripe_shared::PaymentPagesCheckoutSessionTaxIdCollection>,
165    /// Tax and discount details for the computed total amount.
166    pub total_details: Option<stripe_shared::PaymentPagesCheckoutSessionTotalDetails>,
167    /// The UI mode of the Session. Defaults to `hosted`.
168    pub ui_mode: Option<stripe_shared::CheckoutSessionUiMode>,
169    /// The URL to the Checkout Session.
170    /// Applies to Checkout Sessions with `ui_mode: hosted`.
171    /// Redirect customers to this URL to take them to Checkout.
172    /// If you’re using [Custom Domains](https://stripe.com/docs/payments/checkout/custom-domains), the URL will use your subdomain.
173    /// Otherwise, it’ll use `checkout.stripe.com.`.
174    /// This value is only present when the session is active.
175    pub url: Option<String>,
176    /// Wallet-specific configuration for this Checkout Session.
177    pub wallet_options: Option<stripe_shared::CheckoutSessionWalletOptions>,
178}
179#[doc(hidden)]
180pub struct CheckoutSessionBuilder {
181    adaptive_pricing: Option<Option<stripe_shared::PaymentPagesCheckoutSessionAdaptivePricing>>,
182    after_expiration: Option<Option<stripe_shared::PaymentPagesCheckoutSessionAfterExpiration>>,
183    allow_promotion_codes: Option<Option<bool>>,
184    amount_subtotal: Option<Option<i64>>,
185    amount_total: Option<Option<i64>>,
186    automatic_tax: Option<stripe_shared::PaymentPagesCheckoutSessionAutomaticTax>,
187    billing_address_collection:
188        Option<Option<stripe_shared::CheckoutSessionBillingAddressCollection>>,
189    cancel_url: Option<Option<String>>,
190    client_reference_id: Option<Option<String>>,
191    client_secret: Option<Option<String>>,
192    collected_information:
193        Option<Option<stripe_shared::PaymentPagesCheckoutSessionCollectedInformation>>,
194    consent: Option<Option<stripe_shared::PaymentPagesCheckoutSessionConsent>>,
195    consent_collection: Option<Option<stripe_shared::PaymentPagesCheckoutSessionConsentCollection>>,
196    created: Option<stripe_types::Timestamp>,
197    currency: Option<Option<stripe_types::Currency>>,
198    currency_conversion:
199        Option<Option<stripe_shared::PaymentPagesCheckoutSessionCurrencyConversion>>,
200    custom_fields: Option<Vec<stripe_shared::PaymentPagesCheckoutSessionCustomFields>>,
201    custom_text: Option<stripe_shared::PaymentPagesCheckoutSessionCustomText>,
202    customer: Option<Option<stripe_types::Expandable<stripe_shared::Customer>>>,
203    customer_creation: Option<Option<CheckoutSessionCustomerCreation>>,
204    customer_details: Option<Option<stripe_shared::PaymentPagesCheckoutSessionCustomerDetails>>,
205    customer_email: Option<Option<String>>,
206    discounts: Option<Option<Vec<stripe_shared::PaymentPagesCheckoutSessionDiscount>>>,
207    expires_at: Option<stripe_types::Timestamp>,
208    id: Option<stripe_shared::CheckoutSessionId>,
209    invoice: Option<Option<stripe_types::Expandable<stripe_shared::Invoice>>>,
210    invoice_creation: Option<Option<stripe_shared::PaymentPagesCheckoutSessionInvoiceCreation>>,
211    line_items: Option<Option<stripe_types::List<stripe_shared::CheckoutSessionItem>>>,
212    livemode: Option<bool>,
213    locale: Option<Option<stripe_shared::CheckoutSessionLocale>>,
214    metadata: Option<Option<std::collections::HashMap<String, String>>>,
215    mode: Option<stripe_shared::CheckoutSessionMode>,
216    optional_items: Option<Option<Vec<stripe_shared::PaymentPagesCheckoutSessionOptionalItem>>>,
217    payment_intent: Option<Option<stripe_types::Expandable<stripe_shared::PaymentIntent>>>,
218    payment_link: Option<Option<stripe_types::Expandable<stripe_shared::PaymentLink>>>,
219    payment_method_collection: Option<Option<CheckoutSessionPaymentMethodCollection>>,
220    payment_method_configuration_details:
221        Option<Option<stripe_shared::PaymentMethodConfigBizPaymentMethodConfigurationDetails>>,
222    payment_method_options: Option<Option<stripe_shared::CheckoutSessionPaymentMethodOptions>>,
223    payment_method_types: Option<Vec<String>>,
224    payment_status: Option<CheckoutSessionPaymentStatus>,
225    permissions: Option<Option<stripe_shared::PaymentPagesCheckoutSessionPermissions>>,
226    phone_number_collection:
227        Option<Option<stripe_shared::PaymentPagesCheckoutSessionPhoneNumberCollection>>,
228    presentment_details: Option<Option<stripe_shared::PaymentFlowsPaymentIntentPresentmentDetails>>,
229    recovered_from: Option<Option<String>>,
230    redirect_on_completion: Option<Option<stripe_shared::CheckoutSessionRedirectOnCompletion>>,
231    return_url: Option<Option<String>>,
232    saved_payment_method_options:
233        Option<Option<stripe_shared::PaymentPagesCheckoutSessionSavedPaymentMethodOptions>>,
234    setup_intent: Option<Option<stripe_types::Expandable<stripe_shared::SetupIntent>>>,
235    shipping_address_collection:
236        Option<Option<stripe_shared::PaymentPagesCheckoutSessionShippingAddressCollection>>,
237    shipping_cost: Option<Option<stripe_shared::PaymentPagesCheckoutSessionShippingCost>>,
238    shipping_options: Option<Vec<stripe_shared::PaymentPagesCheckoutSessionShippingOption>>,
239    status: Option<Option<stripe_shared::CheckoutSessionStatus>>,
240    submit_type: Option<Option<stripe_shared::CheckoutSessionSubmitType>>,
241    subscription: Option<Option<stripe_types::Expandable<stripe_shared::Subscription>>>,
242    success_url: Option<Option<String>>,
243    tax_id_collection: Option<Option<stripe_shared::PaymentPagesCheckoutSessionTaxIdCollection>>,
244    total_details: Option<Option<stripe_shared::PaymentPagesCheckoutSessionTotalDetails>>,
245    ui_mode: Option<Option<stripe_shared::CheckoutSessionUiMode>>,
246    url: Option<Option<String>>,
247    wallet_options: Option<Option<stripe_shared::CheckoutSessionWalletOptions>>,
248}
249
250#[allow(
251    unused_variables,
252    irrefutable_let_patterns,
253    clippy::let_unit_value,
254    clippy::match_single_binding,
255    clippy::single_match
256)]
257const _: () = {
258    use miniserde::de::{Map, Visitor};
259    use miniserde::json::Value;
260    use miniserde::{make_place, Deserialize, Result};
261    use stripe_types::miniserde_helpers::FromValueOpt;
262    use stripe_types::{MapBuilder, ObjectDeser};
263
264    make_place!(Place);
265
266    impl Deserialize for CheckoutSession {
267        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
268            Place::new(out)
269        }
270    }
271
272    struct Builder<'a> {
273        out: &'a mut Option<CheckoutSession>,
274        builder: CheckoutSessionBuilder,
275    }
276
277    impl Visitor for Place<CheckoutSession> {
278        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
279            Ok(Box::new(Builder {
280                out: &mut self.out,
281                builder: CheckoutSessionBuilder::deser_default(),
282            }))
283        }
284    }
285
286    impl MapBuilder for CheckoutSessionBuilder {
287        type Out = CheckoutSession;
288        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
289            Ok(match k {
290                "adaptive_pricing" => Deserialize::begin(&mut self.adaptive_pricing),
291                "after_expiration" => Deserialize::begin(&mut self.after_expiration),
292                "allow_promotion_codes" => Deserialize::begin(&mut self.allow_promotion_codes),
293                "amount_subtotal" => Deserialize::begin(&mut self.amount_subtotal),
294                "amount_total" => Deserialize::begin(&mut self.amount_total),
295                "automatic_tax" => Deserialize::begin(&mut self.automatic_tax),
296                "billing_address_collection" => {
297                    Deserialize::begin(&mut self.billing_address_collection)
298                }
299                "cancel_url" => Deserialize::begin(&mut self.cancel_url),
300                "client_reference_id" => Deserialize::begin(&mut self.client_reference_id),
301                "client_secret" => Deserialize::begin(&mut self.client_secret),
302                "collected_information" => Deserialize::begin(&mut self.collected_information),
303                "consent" => Deserialize::begin(&mut self.consent),
304                "consent_collection" => Deserialize::begin(&mut self.consent_collection),
305                "created" => Deserialize::begin(&mut self.created),
306                "currency" => Deserialize::begin(&mut self.currency),
307                "currency_conversion" => Deserialize::begin(&mut self.currency_conversion),
308                "custom_fields" => Deserialize::begin(&mut self.custom_fields),
309                "custom_text" => Deserialize::begin(&mut self.custom_text),
310                "customer" => Deserialize::begin(&mut self.customer),
311                "customer_creation" => Deserialize::begin(&mut self.customer_creation),
312                "customer_details" => Deserialize::begin(&mut self.customer_details),
313                "customer_email" => Deserialize::begin(&mut self.customer_email),
314                "discounts" => Deserialize::begin(&mut self.discounts),
315                "expires_at" => Deserialize::begin(&mut self.expires_at),
316                "id" => Deserialize::begin(&mut self.id),
317                "invoice" => Deserialize::begin(&mut self.invoice),
318                "invoice_creation" => Deserialize::begin(&mut self.invoice_creation),
319                "line_items" => Deserialize::begin(&mut self.line_items),
320                "livemode" => Deserialize::begin(&mut self.livemode),
321                "locale" => Deserialize::begin(&mut self.locale),
322                "metadata" => Deserialize::begin(&mut self.metadata),
323                "mode" => Deserialize::begin(&mut self.mode),
324                "optional_items" => Deserialize::begin(&mut self.optional_items),
325                "payment_intent" => Deserialize::begin(&mut self.payment_intent),
326                "payment_link" => Deserialize::begin(&mut self.payment_link),
327                "payment_method_collection" => {
328                    Deserialize::begin(&mut self.payment_method_collection)
329                }
330                "payment_method_configuration_details" => {
331                    Deserialize::begin(&mut self.payment_method_configuration_details)
332                }
333                "payment_method_options" => Deserialize::begin(&mut self.payment_method_options),
334                "payment_method_types" => Deserialize::begin(&mut self.payment_method_types),
335                "payment_status" => Deserialize::begin(&mut self.payment_status),
336                "permissions" => Deserialize::begin(&mut self.permissions),
337                "phone_number_collection" => Deserialize::begin(&mut self.phone_number_collection),
338                "presentment_details" => Deserialize::begin(&mut self.presentment_details),
339                "recovered_from" => Deserialize::begin(&mut self.recovered_from),
340                "redirect_on_completion" => Deserialize::begin(&mut self.redirect_on_completion),
341                "return_url" => Deserialize::begin(&mut self.return_url),
342                "saved_payment_method_options" => {
343                    Deserialize::begin(&mut self.saved_payment_method_options)
344                }
345                "setup_intent" => Deserialize::begin(&mut self.setup_intent),
346                "shipping_address_collection" => {
347                    Deserialize::begin(&mut self.shipping_address_collection)
348                }
349                "shipping_cost" => Deserialize::begin(&mut self.shipping_cost),
350                "shipping_options" => Deserialize::begin(&mut self.shipping_options),
351                "status" => Deserialize::begin(&mut self.status),
352                "submit_type" => Deserialize::begin(&mut self.submit_type),
353                "subscription" => Deserialize::begin(&mut self.subscription),
354                "success_url" => Deserialize::begin(&mut self.success_url),
355                "tax_id_collection" => Deserialize::begin(&mut self.tax_id_collection),
356                "total_details" => Deserialize::begin(&mut self.total_details),
357                "ui_mode" => Deserialize::begin(&mut self.ui_mode),
358                "url" => Deserialize::begin(&mut self.url),
359                "wallet_options" => Deserialize::begin(&mut self.wallet_options),
360
361                _ => <dyn Visitor>::ignore(),
362            })
363        }
364
365        fn deser_default() -> Self {
366            Self {
367                adaptive_pricing: Deserialize::default(),
368                after_expiration: Deserialize::default(),
369                allow_promotion_codes: Deserialize::default(),
370                amount_subtotal: Deserialize::default(),
371                amount_total: Deserialize::default(),
372                automatic_tax: Deserialize::default(),
373                billing_address_collection: Deserialize::default(),
374                cancel_url: Deserialize::default(),
375                client_reference_id: Deserialize::default(),
376                client_secret: Deserialize::default(),
377                collected_information: Deserialize::default(),
378                consent: Deserialize::default(),
379                consent_collection: Deserialize::default(),
380                created: Deserialize::default(),
381                currency: Deserialize::default(),
382                currency_conversion: Deserialize::default(),
383                custom_fields: Deserialize::default(),
384                custom_text: Deserialize::default(),
385                customer: Deserialize::default(),
386                customer_creation: Deserialize::default(),
387                customer_details: Deserialize::default(),
388                customer_email: Deserialize::default(),
389                discounts: Deserialize::default(),
390                expires_at: Deserialize::default(),
391                id: Deserialize::default(),
392                invoice: Deserialize::default(),
393                invoice_creation: Deserialize::default(),
394                line_items: Deserialize::default(),
395                livemode: Deserialize::default(),
396                locale: Deserialize::default(),
397                metadata: Deserialize::default(),
398                mode: Deserialize::default(),
399                optional_items: Deserialize::default(),
400                payment_intent: Deserialize::default(),
401                payment_link: Deserialize::default(),
402                payment_method_collection: Deserialize::default(),
403                payment_method_configuration_details: Deserialize::default(),
404                payment_method_options: Deserialize::default(),
405                payment_method_types: Deserialize::default(),
406                payment_status: Deserialize::default(),
407                permissions: Deserialize::default(),
408                phone_number_collection: Deserialize::default(),
409                presentment_details: Deserialize::default(),
410                recovered_from: Deserialize::default(),
411                redirect_on_completion: Deserialize::default(),
412                return_url: Deserialize::default(),
413                saved_payment_method_options: Deserialize::default(),
414                setup_intent: Deserialize::default(),
415                shipping_address_collection: Deserialize::default(),
416                shipping_cost: Deserialize::default(),
417                shipping_options: Deserialize::default(),
418                status: Deserialize::default(),
419                submit_type: Deserialize::default(),
420                subscription: Deserialize::default(),
421                success_url: Deserialize::default(),
422                tax_id_collection: Deserialize::default(),
423                total_details: Deserialize::default(),
424                ui_mode: Deserialize::default(),
425                url: Deserialize::default(),
426                wallet_options: Deserialize::default(),
427            }
428        }
429
430        fn take_out(&mut self) -> Option<Self::Out> {
431            let (
432                Some(adaptive_pricing),
433                Some(after_expiration),
434                Some(allow_promotion_codes),
435                Some(amount_subtotal),
436                Some(amount_total),
437                Some(automatic_tax),
438                Some(billing_address_collection),
439                Some(cancel_url),
440                Some(client_reference_id),
441                Some(client_secret),
442                Some(collected_information),
443                Some(consent),
444                Some(consent_collection),
445                Some(created),
446                Some(currency),
447                Some(currency_conversion),
448                Some(custom_fields),
449                Some(custom_text),
450                Some(customer),
451                Some(customer_creation),
452                Some(customer_details),
453                Some(customer_email),
454                Some(discounts),
455                Some(expires_at),
456                Some(id),
457                Some(invoice),
458                Some(invoice_creation),
459                Some(line_items),
460                Some(livemode),
461                Some(locale),
462                Some(metadata),
463                Some(mode),
464                Some(optional_items),
465                Some(payment_intent),
466                Some(payment_link),
467                Some(payment_method_collection),
468                Some(payment_method_configuration_details),
469                Some(payment_method_options),
470                Some(payment_method_types),
471                Some(payment_status),
472                Some(permissions),
473                Some(phone_number_collection),
474                Some(presentment_details),
475                Some(recovered_from),
476                Some(redirect_on_completion),
477                Some(return_url),
478                Some(saved_payment_method_options),
479                Some(setup_intent),
480                Some(shipping_address_collection),
481                Some(shipping_cost),
482                Some(shipping_options),
483                Some(status),
484                Some(submit_type),
485                Some(subscription),
486                Some(success_url),
487                Some(tax_id_collection),
488                Some(total_details),
489                Some(ui_mode),
490                Some(url),
491                Some(wallet_options),
492            ) = (
493                self.adaptive_pricing,
494                self.after_expiration.take(),
495                self.allow_promotion_codes,
496                self.amount_subtotal,
497                self.amount_total,
498                self.automatic_tax.take(),
499                self.billing_address_collection,
500                self.cancel_url.take(),
501                self.client_reference_id.take(),
502                self.client_secret.take(),
503                self.collected_information.take(),
504                self.consent,
505                self.consent_collection,
506                self.created,
507                self.currency,
508                self.currency_conversion.take(),
509                self.custom_fields.take(),
510                self.custom_text.take(),
511                self.customer.take(),
512                self.customer_creation,
513                self.customer_details.take(),
514                self.customer_email.take(),
515                self.discounts.take(),
516                self.expires_at,
517                self.id.take(),
518                self.invoice.take(),
519                self.invoice_creation.take(),
520                self.line_items.take(),
521                self.livemode,
522                self.locale.take(),
523                self.metadata.take(),
524                self.mode,
525                self.optional_items.take(),
526                self.payment_intent.take(),
527                self.payment_link.take(),
528                self.payment_method_collection,
529                self.payment_method_configuration_details.take(),
530                self.payment_method_options.take(),
531                self.payment_method_types.take(),
532                self.payment_status,
533                self.permissions,
534                self.phone_number_collection,
535                self.presentment_details,
536                self.recovered_from.take(),
537                self.redirect_on_completion,
538                self.return_url.take(),
539                self.saved_payment_method_options.take(),
540                self.setup_intent.take(),
541                self.shipping_address_collection.take(),
542                self.shipping_cost.take(),
543                self.shipping_options.take(),
544                self.status,
545                self.submit_type,
546                self.subscription.take(),
547                self.success_url.take(),
548                self.tax_id_collection,
549                self.total_details.take(),
550                self.ui_mode,
551                self.url.take(),
552                self.wallet_options,
553            )
554            else {
555                return None;
556            };
557            Some(Self::Out {
558                adaptive_pricing,
559                after_expiration,
560                allow_promotion_codes,
561                amount_subtotal,
562                amount_total,
563                automatic_tax,
564                billing_address_collection,
565                cancel_url,
566                client_reference_id,
567                client_secret,
568                collected_information,
569                consent,
570                consent_collection,
571                created,
572                currency,
573                currency_conversion,
574                custom_fields,
575                custom_text,
576                customer,
577                customer_creation,
578                customer_details,
579                customer_email,
580                discounts,
581                expires_at,
582                id,
583                invoice,
584                invoice_creation,
585                line_items,
586                livemode,
587                locale,
588                metadata,
589                mode,
590                optional_items,
591                payment_intent,
592                payment_link,
593                payment_method_collection,
594                payment_method_configuration_details,
595                payment_method_options,
596                payment_method_types,
597                payment_status,
598                permissions,
599                phone_number_collection,
600                presentment_details,
601                recovered_from,
602                redirect_on_completion,
603                return_url,
604                saved_payment_method_options,
605                setup_intent,
606                shipping_address_collection,
607                shipping_cost,
608                shipping_options,
609                status,
610                submit_type,
611                subscription,
612                success_url,
613                tax_id_collection,
614                total_details,
615                ui_mode,
616                url,
617                wallet_options,
618            })
619        }
620    }
621
622    impl<'a> Map for Builder<'a> {
623        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
624            self.builder.key(k)
625        }
626
627        fn finish(&mut self) -> Result<()> {
628            *self.out = self.builder.take_out();
629            Ok(())
630        }
631    }
632
633    impl ObjectDeser for CheckoutSession {
634        type Builder = CheckoutSessionBuilder;
635    }
636
637    impl FromValueOpt for CheckoutSession {
638        fn from_value(v: Value) -> Option<Self> {
639            let Value::Object(obj) = v else {
640                return None;
641            };
642            let mut b = CheckoutSessionBuilder::deser_default();
643            for (k, v) in obj {
644                match k.as_str() {
645                    "adaptive_pricing" => b.adaptive_pricing = FromValueOpt::from_value(v),
646                    "after_expiration" => b.after_expiration = FromValueOpt::from_value(v),
647                    "allow_promotion_codes" => {
648                        b.allow_promotion_codes = FromValueOpt::from_value(v)
649                    }
650                    "amount_subtotal" => b.amount_subtotal = FromValueOpt::from_value(v),
651                    "amount_total" => b.amount_total = FromValueOpt::from_value(v),
652                    "automatic_tax" => b.automatic_tax = FromValueOpt::from_value(v),
653                    "billing_address_collection" => {
654                        b.billing_address_collection = FromValueOpt::from_value(v)
655                    }
656                    "cancel_url" => b.cancel_url = FromValueOpt::from_value(v),
657                    "client_reference_id" => b.client_reference_id = FromValueOpt::from_value(v),
658                    "client_secret" => b.client_secret = FromValueOpt::from_value(v),
659                    "collected_information" => {
660                        b.collected_information = FromValueOpt::from_value(v)
661                    }
662                    "consent" => b.consent = FromValueOpt::from_value(v),
663                    "consent_collection" => b.consent_collection = FromValueOpt::from_value(v),
664                    "created" => b.created = FromValueOpt::from_value(v),
665                    "currency" => b.currency = FromValueOpt::from_value(v),
666                    "currency_conversion" => b.currency_conversion = FromValueOpt::from_value(v),
667                    "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
668                    "custom_text" => b.custom_text = FromValueOpt::from_value(v),
669                    "customer" => b.customer = FromValueOpt::from_value(v),
670                    "customer_creation" => b.customer_creation = FromValueOpt::from_value(v),
671                    "customer_details" => b.customer_details = FromValueOpt::from_value(v),
672                    "customer_email" => b.customer_email = FromValueOpt::from_value(v),
673                    "discounts" => b.discounts = FromValueOpt::from_value(v),
674                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
675                    "id" => b.id = FromValueOpt::from_value(v),
676                    "invoice" => b.invoice = FromValueOpt::from_value(v),
677                    "invoice_creation" => b.invoice_creation = FromValueOpt::from_value(v),
678                    "line_items" => b.line_items = FromValueOpt::from_value(v),
679                    "livemode" => b.livemode = FromValueOpt::from_value(v),
680                    "locale" => b.locale = FromValueOpt::from_value(v),
681                    "metadata" => b.metadata = FromValueOpt::from_value(v),
682                    "mode" => b.mode = FromValueOpt::from_value(v),
683                    "optional_items" => b.optional_items = FromValueOpt::from_value(v),
684                    "payment_intent" => b.payment_intent = FromValueOpt::from_value(v),
685                    "payment_link" => b.payment_link = FromValueOpt::from_value(v),
686                    "payment_method_collection" => {
687                        b.payment_method_collection = FromValueOpt::from_value(v)
688                    }
689                    "payment_method_configuration_details" => {
690                        b.payment_method_configuration_details = FromValueOpt::from_value(v)
691                    }
692                    "payment_method_options" => {
693                        b.payment_method_options = FromValueOpt::from_value(v)
694                    }
695                    "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
696                    "payment_status" => b.payment_status = FromValueOpt::from_value(v),
697                    "permissions" => b.permissions = FromValueOpt::from_value(v),
698                    "phone_number_collection" => {
699                        b.phone_number_collection = FromValueOpt::from_value(v)
700                    }
701                    "presentment_details" => b.presentment_details = FromValueOpt::from_value(v),
702                    "recovered_from" => b.recovered_from = FromValueOpt::from_value(v),
703                    "redirect_on_completion" => {
704                        b.redirect_on_completion = FromValueOpt::from_value(v)
705                    }
706                    "return_url" => b.return_url = FromValueOpt::from_value(v),
707                    "saved_payment_method_options" => {
708                        b.saved_payment_method_options = FromValueOpt::from_value(v)
709                    }
710                    "setup_intent" => b.setup_intent = FromValueOpt::from_value(v),
711                    "shipping_address_collection" => {
712                        b.shipping_address_collection = FromValueOpt::from_value(v)
713                    }
714                    "shipping_cost" => b.shipping_cost = FromValueOpt::from_value(v),
715                    "shipping_options" => b.shipping_options = FromValueOpt::from_value(v),
716                    "status" => b.status = FromValueOpt::from_value(v),
717                    "submit_type" => b.submit_type = FromValueOpt::from_value(v),
718                    "subscription" => b.subscription = FromValueOpt::from_value(v),
719                    "success_url" => b.success_url = FromValueOpt::from_value(v),
720                    "tax_id_collection" => b.tax_id_collection = FromValueOpt::from_value(v),
721                    "total_details" => b.total_details = FromValueOpt::from_value(v),
722                    "ui_mode" => b.ui_mode = FromValueOpt::from_value(v),
723                    "url" => b.url = FromValueOpt::from_value(v),
724                    "wallet_options" => b.wallet_options = FromValueOpt::from_value(v),
725
726                    _ => {}
727                }
728            }
729            b.take_out()
730        }
731    }
732};
733#[cfg(feature = "serialize")]
734impl serde::Serialize for CheckoutSession {
735    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
736        use serde::ser::SerializeStruct;
737        let mut s = s.serialize_struct("CheckoutSession", 61)?;
738        s.serialize_field("adaptive_pricing", &self.adaptive_pricing)?;
739        s.serialize_field("after_expiration", &self.after_expiration)?;
740        s.serialize_field("allow_promotion_codes", &self.allow_promotion_codes)?;
741        s.serialize_field("amount_subtotal", &self.amount_subtotal)?;
742        s.serialize_field("amount_total", &self.amount_total)?;
743        s.serialize_field("automatic_tax", &self.automatic_tax)?;
744        s.serialize_field("billing_address_collection", &self.billing_address_collection)?;
745        s.serialize_field("cancel_url", &self.cancel_url)?;
746        s.serialize_field("client_reference_id", &self.client_reference_id)?;
747        s.serialize_field("client_secret", &self.client_secret)?;
748        s.serialize_field("collected_information", &self.collected_information)?;
749        s.serialize_field("consent", &self.consent)?;
750        s.serialize_field("consent_collection", &self.consent_collection)?;
751        s.serialize_field("created", &self.created)?;
752        s.serialize_field("currency", &self.currency)?;
753        s.serialize_field("currency_conversion", &self.currency_conversion)?;
754        s.serialize_field("custom_fields", &self.custom_fields)?;
755        s.serialize_field("custom_text", &self.custom_text)?;
756        s.serialize_field("customer", &self.customer)?;
757        s.serialize_field("customer_creation", &self.customer_creation)?;
758        s.serialize_field("customer_details", &self.customer_details)?;
759        s.serialize_field("customer_email", &self.customer_email)?;
760        s.serialize_field("discounts", &self.discounts)?;
761        s.serialize_field("expires_at", &self.expires_at)?;
762        s.serialize_field("id", &self.id)?;
763        s.serialize_field("invoice", &self.invoice)?;
764        s.serialize_field("invoice_creation", &self.invoice_creation)?;
765        s.serialize_field("line_items", &self.line_items)?;
766        s.serialize_field("livemode", &self.livemode)?;
767        s.serialize_field("locale", &self.locale)?;
768        s.serialize_field("metadata", &self.metadata)?;
769        s.serialize_field("mode", &self.mode)?;
770        s.serialize_field("optional_items", &self.optional_items)?;
771        s.serialize_field("payment_intent", &self.payment_intent)?;
772        s.serialize_field("payment_link", &self.payment_link)?;
773        s.serialize_field("payment_method_collection", &self.payment_method_collection)?;
774        s.serialize_field(
775            "payment_method_configuration_details",
776            &self.payment_method_configuration_details,
777        )?;
778        s.serialize_field("payment_method_options", &self.payment_method_options)?;
779        s.serialize_field("payment_method_types", &self.payment_method_types)?;
780        s.serialize_field("payment_status", &self.payment_status)?;
781        s.serialize_field("permissions", &self.permissions)?;
782        s.serialize_field("phone_number_collection", &self.phone_number_collection)?;
783        s.serialize_field("presentment_details", &self.presentment_details)?;
784        s.serialize_field("recovered_from", &self.recovered_from)?;
785        s.serialize_field("redirect_on_completion", &self.redirect_on_completion)?;
786        s.serialize_field("return_url", &self.return_url)?;
787        s.serialize_field("saved_payment_method_options", &self.saved_payment_method_options)?;
788        s.serialize_field("setup_intent", &self.setup_intent)?;
789        s.serialize_field("shipping_address_collection", &self.shipping_address_collection)?;
790        s.serialize_field("shipping_cost", &self.shipping_cost)?;
791        s.serialize_field("shipping_options", &self.shipping_options)?;
792        s.serialize_field("status", &self.status)?;
793        s.serialize_field("submit_type", &self.submit_type)?;
794        s.serialize_field("subscription", &self.subscription)?;
795        s.serialize_field("success_url", &self.success_url)?;
796        s.serialize_field("tax_id_collection", &self.tax_id_collection)?;
797        s.serialize_field("total_details", &self.total_details)?;
798        s.serialize_field("ui_mode", &self.ui_mode)?;
799        s.serialize_field("url", &self.url)?;
800        s.serialize_field("wallet_options", &self.wallet_options)?;
801
802        s.serialize_field("object", "checkout.session")?;
803        s.end()
804    }
805}
806/// Configure whether a Checkout Session creates a Customer when the Checkout Session completes.
807#[derive(Copy, Clone, Eq, PartialEq)]
808pub enum CheckoutSessionCustomerCreation {
809    Always,
810    IfRequired,
811}
812impl CheckoutSessionCustomerCreation {
813    pub fn as_str(self) -> &'static str {
814        use CheckoutSessionCustomerCreation::*;
815        match self {
816            Always => "always",
817            IfRequired => "if_required",
818        }
819    }
820}
821
822impl std::str::FromStr for CheckoutSessionCustomerCreation {
823    type Err = stripe_types::StripeParseError;
824    fn from_str(s: &str) -> Result<Self, Self::Err> {
825        use CheckoutSessionCustomerCreation::*;
826        match s {
827            "always" => Ok(Always),
828            "if_required" => Ok(IfRequired),
829            _ => Err(stripe_types::StripeParseError),
830        }
831    }
832}
833impl std::fmt::Display for CheckoutSessionCustomerCreation {
834    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
835        f.write_str(self.as_str())
836    }
837}
838
839impl std::fmt::Debug for CheckoutSessionCustomerCreation {
840    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
841        f.write_str(self.as_str())
842    }
843}
844#[cfg(feature = "serialize")]
845impl serde::Serialize for CheckoutSessionCustomerCreation {
846    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
847    where
848        S: serde::Serializer,
849    {
850        serializer.serialize_str(self.as_str())
851    }
852}
853impl miniserde::Deserialize for CheckoutSessionCustomerCreation {
854    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
855        crate::Place::new(out)
856    }
857}
858
859impl miniserde::de::Visitor for crate::Place<CheckoutSessionCustomerCreation> {
860    fn string(&mut self, s: &str) -> miniserde::Result<()> {
861        use std::str::FromStr;
862        self.out =
863            Some(CheckoutSessionCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?);
864        Ok(())
865    }
866}
867
868stripe_types::impl_from_val_with_from_str!(CheckoutSessionCustomerCreation);
869#[cfg(feature = "deserialize")]
870impl<'de> serde::Deserialize<'de> for CheckoutSessionCustomerCreation {
871    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
872        use std::str::FromStr;
873        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
874        Self::from_str(&s).map_err(|_| {
875            serde::de::Error::custom("Unknown value for CheckoutSessionCustomerCreation")
876        })
877    }
878}
879/// Configure whether a Checkout Session should collect a payment method. Defaults to `always`.
880#[derive(Copy, Clone, Eq, PartialEq)]
881pub enum CheckoutSessionPaymentMethodCollection {
882    Always,
883    IfRequired,
884}
885impl CheckoutSessionPaymentMethodCollection {
886    pub fn as_str(self) -> &'static str {
887        use CheckoutSessionPaymentMethodCollection::*;
888        match self {
889            Always => "always",
890            IfRequired => "if_required",
891        }
892    }
893}
894
895impl std::str::FromStr for CheckoutSessionPaymentMethodCollection {
896    type Err = stripe_types::StripeParseError;
897    fn from_str(s: &str) -> Result<Self, Self::Err> {
898        use CheckoutSessionPaymentMethodCollection::*;
899        match s {
900            "always" => Ok(Always),
901            "if_required" => Ok(IfRequired),
902            _ => Err(stripe_types::StripeParseError),
903        }
904    }
905}
906impl std::fmt::Display for CheckoutSessionPaymentMethodCollection {
907    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
908        f.write_str(self.as_str())
909    }
910}
911
912impl std::fmt::Debug for CheckoutSessionPaymentMethodCollection {
913    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
914        f.write_str(self.as_str())
915    }
916}
917#[cfg(feature = "serialize")]
918impl serde::Serialize for CheckoutSessionPaymentMethodCollection {
919    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
920    where
921        S: serde::Serializer,
922    {
923        serializer.serialize_str(self.as_str())
924    }
925}
926impl miniserde::Deserialize for CheckoutSessionPaymentMethodCollection {
927    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
928        crate::Place::new(out)
929    }
930}
931
932impl miniserde::de::Visitor for crate::Place<CheckoutSessionPaymentMethodCollection> {
933    fn string(&mut self, s: &str) -> miniserde::Result<()> {
934        use std::str::FromStr;
935        self.out = Some(
936            CheckoutSessionPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?,
937        );
938        Ok(())
939    }
940}
941
942stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentMethodCollection);
943#[cfg(feature = "deserialize")]
944impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentMethodCollection {
945    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
946        use std::str::FromStr;
947        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
948        Self::from_str(&s).map_err(|_| {
949            serde::de::Error::custom("Unknown value for CheckoutSessionPaymentMethodCollection")
950        })
951    }
952}
953/// The payment status of the Checkout Session, one of `paid`, `unpaid`, or `no_payment_required`.
954/// You can use this value to decide when to fulfill your customer's order.
955#[derive(Copy, Clone, Eq, PartialEq)]
956pub enum CheckoutSessionPaymentStatus {
957    NoPaymentRequired,
958    Paid,
959    Unpaid,
960}
961impl CheckoutSessionPaymentStatus {
962    pub fn as_str(self) -> &'static str {
963        use CheckoutSessionPaymentStatus::*;
964        match self {
965            NoPaymentRequired => "no_payment_required",
966            Paid => "paid",
967            Unpaid => "unpaid",
968        }
969    }
970}
971
972impl std::str::FromStr for CheckoutSessionPaymentStatus {
973    type Err = stripe_types::StripeParseError;
974    fn from_str(s: &str) -> Result<Self, Self::Err> {
975        use CheckoutSessionPaymentStatus::*;
976        match s {
977            "no_payment_required" => Ok(NoPaymentRequired),
978            "paid" => Ok(Paid),
979            "unpaid" => Ok(Unpaid),
980            _ => Err(stripe_types::StripeParseError),
981        }
982    }
983}
984impl std::fmt::Display for CheckoutSessionPaymentStatus {
985    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
986        f.write_str(self.as_str())
987    }
988}
989
990impl std::fmt::Debug for CheckoutSessionPaymentStatus {
991    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
992        f.write_str(self.as_str())
993    }
994}
995#[cfg(feature = "serialize")]
996impl serde::Serialize for CheckoutSessionPaymentStatus {
997    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
998    where
999        S: serde::Serializer,
1000    {
1001        serializer.serialize_str(self.as_str())
1002    }
1003}
1004impl miniserde::Deserialize for CheckoutSessionPaymentStatus {
1005    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1006        crate::Place::new(out)
1007    }
1008}
1009
1010impl miniserde::de::Visitor for crate::Place<CheckoutSessionPaymentStatus> {
1011    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1012        use std::str::FromStr;
1013        self.out = Some(CheckoutSessionPaymentStatus::from_str(s).map_err(|_| miniserde::Error)?);
1014        Ok(())
1015    }
1016}
1017
1018stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentStatus);
1019#[cfg(feature = "deserialize")]
1020impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentStatus {
1021    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1022        use std::str::FromStr;
1023        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1024        Self::from_str(&s)
1025            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionPaymentStatus"))
1026    }
1027}
1028impl stripe_types::Object for CheckoutSession {
1029    type Id = stripe_shared::CheckoutSessionId;
1030    fn id(&self) -> &Self::Id {
1031        &self.id
1032    }
1033
1034    fn into_id(self) -> Self::Id {
1035        self.id
1036    }
1037}
1038stripe_types::def_id!(CheckoutSessionId);
1039#[derive(Copy, Clone, Eq, PartialEq)]
1040pub enum CheckoutSessionBillingAddressCollection {
1041    Auto,
1042    Required,
1043}
1044impl CheckoutSessionBillingAddressCollection {
1045    pub fn as_str(self) -> &'static str {
1046        use CheckoutSessionBillingAddressCollection::*;
1047        match self {
1048            Auto => "auto",
1049            Required => "required",
1050        }
1051    }
1052}
1053
1054impl std::str::FromStr for CheckoutSessionBillingAddressCollection {
1055    type Err = stripe_types::StripeParseError;
1056    fn from_str(s: &str) -> Result<Self, Self::Err> {
1057        use CheckoutSessionBillingAddressCollection::*;
1058        match s {
1059            "auto" => Ok(Auto),
1060            "required" => Ok(Required),
1061            _ => Err(stripe_types::StripeParseError),
1062        }
1063    }
1064}
1065impl std::fmt::Display for CheckoutSessionBillingAddressCollection {
1066    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1067        f.write_str(self.as_str())
1068    }
1069}
1070
1071impl std::fmt::Debug for CheckoutSessionBillingAddressCollection {
1072    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1073        f.write_str(self.as_str())
1074    }
1075}
1076impl serde::Serialize for CheckoutSessionBillingAddressCollection {
1077    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1078    where
1079        S: serde::Serializer,
1080    {
1081        serializer.serialize_str(self.as_str())
1082    }
1083}
1084impl miniserde::Deserialize for CheckoutSessionBillingAddressCollection {
1085    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1086        crate::Place::new(out)
1087    }
1088}
1089
1090impl miniserde::de::Visitor for crate::Place<CheckoutSessionBillingAddressCollection> {
1091    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1092        use std::str::FromStr;
1093        self.out = Some(
1094            CheckoutSessionBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?,
1095        );
1096        Ok(())
1097    }
1098}
1099
1100stripe_types::impl_from_val_with_from_str!(CheckoutSessionBillingAddressCollection);
1101#[cfg(feature = "deserialize")]
1102impl<'de> serde::Deserialize<'de> for CheckoutSessionBillingAddressCollection {
1103    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1104        use std::str::FromStr;
1105        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1106        Self::from_str(&s).map_err(|_| {
1107            serde::de::Error::custom("Unknown value for CheckoutSessionBillingAddressCollection")
1108        })
1109    }
1110}
1111#[derive(Clone, Eq, PartialEq)]
1112#[non_exhaustive]
1113pub enum CheckoutSessionLocale {
1114    Auto,
1115    Bg,
1116    Cs,
1117    Da,
1118    De,
1119    El,
1120    En,
1121    EnMinusGb,
1122    Es,
1123    EsMinus419,
1124    Et,
1125    Fi,
1126    Fil,
1127    Fr,
1128    FrMinusCa,
1129    Hr,
1130    Hu,
1131    Id,
1132    It,
1133    Ja,
1134    Ko,
1135    Lt,
1136    Lv,
1137    Ms,
1138    Mt,
1139    Nb,
1140    Nl,
1141    Pl,
1142    Pt,
1143    PtMinusBr,
1144    Ro,
1145    Ru,
1146    Sk,
1147    Sl,
1148    Sv,
1149    Th,
1150    Tr,
1151    Vi,
1152    Zh,
1153    ZhMinusHk,
1154    ZhMinusTw,
1155    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1156    Unknown(String),
1157}
1158impl CheckoutSessionLocale {
1159    pub fn as_str(&self) -> &str {
1160        use CheckoutSessionLocale::*;
1161        match self {
1162            Auto => "auto",
1163            Bg => "bg",
1164            Cs => "cs",
1165            Da => "da",
1166            De => "de",
1167            El => "el",
1168            En => "en",
1169            EnMinusGb => "en-GB",
1170            Es => "es",
1171            EsMinus419 => "es-419",
1172            Et => "et",
1173            Fi => "fi",
1174            Fil => "fil",
1175            Fr => "fr",
1176            FrMinusCa => "fr-CA",
1177            Hr => "hr",
1178            Hu => "hu",
1179            Id => "id",
1180            It => "it",
1181            Ja => "ja",
1182            Ko => "ko",
1183            Lt => "lt",
1184            Lv => "lv",
1185            Ms => "ms",
1186            Mt => "mt",
1187            Nb => "nb",
1188            Nl => "nl",
1189            Pl => "pl",
1190            Pt => "pt",
1191            PtMinusBr => "pt-BR",
1192            Ro => "ro",
1193            Ru => "ru",
1194            Sk => "sk",
1195            Sl => "sl",
1196            Sv => "sv",
1197            Th => "th",
1198            Tr => "tr",
1199            Vi => "vi",
1200            Zh => "zh",
1201            ZhMinusHk => "zh-HK",
1202            ZhMinusTw => "zh-TW",
1203            Unknown(v) => v,
1204        }
1205    }
1206}
1207
1208impl std::str::FromStr for CheckoutSessionLocale {
1209    type Err = std::convert::Infallible;
1210    fn from_str(s: &str) -> Result<Self, Self::Err> {
1211        use CheckoutSessionLocale::*;
1212        match s {
1213            "auto" => Ok(Auto),
1214            "bg" => Ok(Bg),
1215            "cs" => Ok(Cs),
1216            "da" => Ok(Da),
1217            "de" => Ok(De),
1218            "el" => Ok(El),
1219            "en" => Ok(En),
1220            "en-GB" => Ok(EnMinusGb),
1221            "es" => Ok(Es),
1222            "es-419" => Ok(EsMinus419),
1223            "et" => Ok(Et),
1224            "fi" => Ok(Fi),
1225            "fil" => Ok(Fil),
1226            "fr" => Ok(Fr),
1227            "fr-CA" => Ok(FrMinusCa),
1228            "hr" => Ok(Hr),
1229            "hu" => Ok(Hu),
1230            "id" => Ok(Id),
1231            "it" => Ok(It),
1232            "ja" => Ok(Ja),
1233            "ko" => Ok(Ko),
1234            "lt" => Ok(Lt),
1235            "lv" => Ok(Lv),
1236            "ms" => Ok(Ms),
1237            "mt" => Ok(Mt),
1238            "nb" => Ok(Nb),
1239            "nl" => Ok(Nl),
1240            "pl" => Ok(Pl),
1241            "pt" => Ok(Pt),
1242            "pt-BR" => Ok(PtMinusBr),
1243            "ro" => Ok(Ro),
1244            "ru" => Ok(Ru),
1245            "sk" => Ok(Sk),
1246            "sl" => Ok(Sl),
1247            "sv" => Ok(Sv),
1248            "th" => Ok(Th),
1249            "tr" => Ok(Tr),
1250            "vi" => Ok(Vi),
1251            "zh" => Ok(Zh),
1252            "zh-HK" => Ok(ZhMinusHk),
1253            "zh-TW" => Ok(ZhMinusTw),
1254            v => Ok(Unknown(v.to_owned())),
1255        }
1256    }
1257}
1258impl std::fmt::Display for CheckoutSessionLocale {
1259    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1260        f.write_str(self.as_str())
1261    }
1262}
1263
1264impl std::fmt::Debug for CheckoutSessionLocale {
1265    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1266        f.write_str(self.as_str())
1267    }
1268}
1269impl serde::Serialize for CheckoutSessionLocale {
1270    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1271    where
1272        S: serde::Serializer,
1273    {
1274        serializer.serialize_str(self.as_str())
1275    }
1276}
1277impl miniserde::Deserialize for CheckoutSessionLocale {
1278    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1279        crate::Place::new(out)
1280    }
1281}
1282
1283impl miniserde::de::Visitor for crate::Place<CheckoutSessionLocale> {
1284    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1285        use std::str::FromStr;
1286        self.out = Some(CheckoutSessionLocale::from_str(s).unwrap());
1287        Ok(())
1288    }
1289}
1290
1291stripe_types::impl_from_val_with_from_str!(CheckoutSessionLocale);
1292#[cfg(feature = "deserialize")]
1293impl<'de> serde::Deserialize<'de> for CheckoutSessionLocale {
1294    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1295        use std::str::FromStr;
1296        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1297        Ok(Self::from_str(&s).unwrap())
1298    }
1299}
1300#[derive(Copy, Clone, Eq, PartialEq)]
1301pub enum CheckoutSessionMode {
1302    Payment,
1303    Setup,
1304    Subscription,
1305}
1306impl CheckoutSessionMode {
1307    pub fn as_str(self) -> &'static str {
1308        use CheckoutSessionMode::*;
1309        match self {
1310            Payment => "payment",
1311            Setup => "setup",
1312            Subscription => "subscription",
1313        }
1314    }
1315}
1316
1317impl std::str::FromStr for CheckoutSessionMode {
1318    type Err = stripe_types::StripeParseError;
1319    fn from_str(s: &str) -> Result<Self, Self::Err> {
1320        use CheckoutSessionMode::*;
1321        match s {
1322            "payment" => Ok(Payment),
1323            "setup" => Ok(Setup),
1324            "subscription" => Ok(Subscription),
1325            _ => Err(stripe_types::StripeParseError),
1326        }
1327    }
1328}
1329impl std::fmt::Display for CheckoutSessionMode {
1330    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1331        f.write_str(self.as_str())
1332    }
1333}
1334
1335impl std::fmt::Debug for CheckoutSessionMode {
1336    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1337        f.write_str(self.as_str())
1338    }
1339}
1340impl serde::Serialize for CheckoutSessionMode {
1341    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1342    where
1343        S: serde::Serializer,
1344    {
1345        serializer.serialize_str(self.as_str())
1346    }
1347}
1348impl miniserde::Deserialize for CheckoutSessionMode {
1349    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1350        crate::Place::new(out)
1351    }
1352}
1353
1354impl miniserde::de::Visitor for crate::Place<CheckoutSessionMode> {
1355    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1356        use std::str::FromStr;
1357        self.out = Some(CheckoutSessionMode::from_str(s).map_err(|_| miniserde::Error)?);
1358        Ok(())
1359    }
1360}
1361
1362stripe_types::impl_from_val_with_from_str!(CheckoutSessionMode);
1363#[cfg(feature = "deserialize")]
1364impl<'de> serde::Deserialize<'de> for CheckoutSessionMode {
1365    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1366        use std::str::FromStr;
1367        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1368        Self::from_str(&s)
1369            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionMode"))
1370    }
1371}
1372#[derive(Copy, Clone, Eq, PartialEq)]
1373pub enum CheckoutSessionRedirectOnCompletion {
1374    Always,
1375    IfRequired,
1376    Never,
1377}
1378impl CheckoutSessionRedirectOnCompletion {
1379    pub fn as_str(self) -> &'static str {
1380        use CheckoutSessionRedirectOnCompletion::*;
1381        match self {
1382            Always => "always",
1383            IfRequired => "if_required",
1384            Never => "never",
1385        }
1386    }
1387}
1388
1389impl std::str::FromStr for CheckoutSessionRedirectOnCompletion {
1390    type Err = stripe_types::StripeParseError;
1391    fn from_str(s: &str) -> Result<Self, Self::Err> {
1392        use CheckoutSessionRedirectOnCompletion::*;
1393        match s {
1394            "always" => Ok(Always),
1395            "if_required" => Ok(IfRequired),
1396            "never" => Ok(Never),
1397            _ => Err(stripe_types::StripeParseError),
1398        }
1399    }
1400}
1401impl std::fmt::Display for CheckoutSessionRedirectOnCompletion {
1402    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1403        f.write_str(self.as_str())
1404    }
1405}
1406
1407impl std::fmt::Debug for CheckoutSessionRedirectOnCompletion {
1408    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1409        f.write_str(self.as_str())
1410    }
1411}
1412impl serde::Serialize for CheckoutSessionRedirectOnCompletion {
1413    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1414    where
1415        S: serde::Serializer,
1416    {
1417        serializer.serialize_str(self.as_str())
1418    }
1419}
1420impl miniserde::Deserialize for CheckoutSessionRedirectOnCompletion {
1421    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1422        crate::Place::new(out)
1423    }
1424}
1425
1426impl miniserde::de::Visitor for crate::Place<CheckoutSessionRedirectOnCompletion> {
1427    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1428        use std::str::FromStr;
1429        self.out =
1430            Some(CheckoutSessionRedirectOnCompletion::from_str(s).map_err(|_| miniserde::Error)?);
1431        Ok(())
1432    }
1433}
1434
1435stripe_types::impl_from_val_with_from_str!(CheckoutSessionRedirectOnCompletion);
1436#[cfg(feature = "deserialize")]
1437impl<'de> serde::Deserialize<'de> for CheckoutSessionRedirectOnCompletion {
1438    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1439        use std::str::FromStr;
1440        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1441        Self::from_str(&s).map_err(|_| {
1442            serde::de::Error::custom("Unknown value for CheckoutSessionRedirectOnCompletion")
1443        })
1444    }
1445}
1446#[derive(Copy, Clone, Eq, PartialEq)]
1447pub enum CheckoutSessionStatus {
1448    Complete,
1449    Expired,
1450    Open,
1451}
1452impl CheckoutSessionStatus {
1453    pub fn as_str(self) -> &'static str {
1454        use CheckoutSessionStatus::*;
1455        match self {
1456            Complete => "complete",
1457            Expired => "expired",
1458            Open => "open",
1459        }
1460    }
1461}
1462
1463impl std::str::FromStr for CheckoutSessionStatus {
1464    type Err = stripe_types::StripeParseError;
1465    fn from_str(s: &str) -> Result<Self, Self::Err> {
1466        use CheckoutSessionStatus::*;
1467        match s {
1468            "complete" => Ok(Complete),
1469            "expired" => Ok(Expired),
1470            "open" => Ok(Open),
1471            _ => Err(stripe_types::StripeParseError),
1472        }
1473    }
1474}
1475impl std::fmt::Display for CheckoutSessionStatus {
1476    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1477        f.write_str(self.as_str())
1478    }
1479}
1480
1481impl std::fmt::Debug for CheckoutSessionStatus {
1482    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1483        f.write_str(self.as_str())
1484    }
1485}
1486impl serde::Serialize for CheckoutSessionStatus {
1487    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1488    where
1489        S: serde::Serializer,
1490    {
1491        serializer.serialize_str(self.as_str())
1492    }
1493}
1494impl miniserde::Deserialize for CheckoutSessionStatus {
1495    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1496        crate::Place::new(out)
1497    }
1498}
1499
1500impl miniserde::de::Visitor for crate::Place<CheckoutSessionStatus> {
1501    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1502        use std::str::FromStr;
1503        self.out = Some(CheckoutSessionStatus::from_str(s).map_err(|_| miniserde::Error)?);
1504        Ok(())
1505    }
1506}
1507
1508stripe_types::impl_from_val_with_from_str!(CheckoutSessionStatus);
1509#[cfg(feature = "deserialize")]
1510impl<'de> serde::Deserialize<'de> for CheckoutSessionStatus {
1511    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1512        use std::str::FromStr;
1513        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1514        Self::from_str(&s)
1515            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionStatus"))
1516    }
1517}
1518#[derive(Copy, Clone, Eq, PartialEq)]
1519pub enum CheckoutSessionSubmitType {
1520    Auto,
1521    Book,
1522    Donate,
1523    Pay,
1524    Subscribe,
1525}
1526impl CheckoutSessionSubmitType {
1527    pub fn as_str(self) -> &'static str {
1528        use CheckoutSessionSubmitType::*;
1529        match self {
1530            Auto => "auto",
1531            Book => "book",
1532            Donate => "donate",
1533            Pay => "pay",
1534            Subscribe => "subscribe",
1535        }
1536    }
1537}
1538
1539impl std::str::FromStr for CheckoutSessionSubmitType {
1540    type Err = stripe_types::StripeParseError;
1541    fn from_str(s: &str) -> Result<Self, Self::Err> {
1542        use CheckoutSessionSubmitType::*;
1543        match s {
1544            "auto" => Ok(Auto),
1545            "book" => Ok(Book),
1546            "donate" => Ok(Donate),
1547            "pay" => Ok(Pay),
1548            "subscribe" => Ok(Subscribe),
1549            _ => Err(stripe_types::StripeParseError),
1550        }
1551    }
1552}
1553impl std::fmt::Display for CheckoutSessionSubmitType {
1554    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1555        f.write_str(self.as_str())
1556    }
1557}
1558
1559impl std::fmt::Debug for CheckoutSessionSubmitType {
1560    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1561        f.write_str(self.as_str())
1562    }
1563}
1564impl serde::Serialize for CheckoutSessionSubmitType {
1565    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1566    where
1567        S: serde::Serializer,
1568    {
1569        serializer.serialize_str(self.as_str())
1570    }
1571}
1572impl miniserde::Deserialize for CheckoutSessionSubmitType {
1573    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1574        crate::Place::new(out)
1575    }
1576}
1577
1578impl miniserde::de::Visitor for crate::Place<CheckoutSessionSubmitType> {
1579    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1580        use std::str::FromStr;
1581        self.out = Some(CheckoutSessionSubmitType::from_str(s).map_err(|_| miniserde::Error)?);
1582        Ok(())
1583    }
1584}
1585
1586stripe_types::impl_from_val_with_from_str!(CheckoutSessionSubmitType);
1587#[cfg(feature = "deserialize")]
1588impl<'de> serde::Deserialize<'de> for CheckoutSessionSubmitType {
1589    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1590        use std::str::FromStr;
1591        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1592        Self::from_str(&s)
1593            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionSubmitType"))
1594    }
1595}
1596#[derive(Copy, Clone, Eq, PartialEq)]
1597pub enum CheckoutSessionUiMode {
1598    Custom,
1599    Embedded,
1600    Hosted,
1601}
1602impl CheckoutSessionUiMode {
1603    pub fn as_str(self) -> &'static str {
1604        use CheckoutSessionUiMode::*;
1605        match self {
1606            Custom => "custom",
1607            Embedded => "embedded",
1608            Hosted => "hosted",
1609        }
1610    }
1611}
1612
1613impl std::str::FromStr for CheckoutSessionUiMode {
1614    type Err = stripe_types::StripeParseError;
1615    fn from_str(s: &str) -> Result<Self, Self::Err> {
1616        use CheckoutSessionUiMode::*;
1617        match s {
1618            "custom" => Ok(Custom),
1619            "embedded" => Ok(Embedded),
1620            "hosted" => Ok(Hosted),
1621            _ => Err(stripe_types::StripeParseError),
1622        }
1623    }
1624}
1625impl std::fmt::Display for CheckoutSessionUiMode {
1626    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1627        f.write_str(self.as_str())
1628    }
1629}
1630
1631impl std::fmt::Debug for CheckoutSessionUiMode {
1632    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1633        f.write_str(self.as_str())
1634    }
1635}
1636impl serde::Serialize for CheckoutSessionUiMode {
1637    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1638    where
1639        S: serde::Serializer,
1640    {
1641        serializer.serialize_str(self.as_str())
1642    }
1643}
1644impl miniserde::Deserialize for CheckoutSessionUiMode {
1645    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1646        crate::Place::new(out)
1647    }
1648}
1649
1650impl miniserde::de::Visitor for crate::Place<CheckoutSessionUiMode> {
1651    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1652        use std::str::FromStr;
1653        self.out = Some(CheckoutSessionUiMode::from_str(s).map_err(|_| miniserde::Error)?);
1654        Ok(())
1655    }
1656}
1657
1658stripe_types::impl_from_val_with_from_str!(CheckoutSessionUiMode);
1659#[cfg(feature = "deserialize")]
1660impl<'de> serde::Deserialize<'de> for CheckoutSessionUiMode {
1661    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1662        use std::str::FromStr;
1663        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1664        Self::from_str(&s)
1665            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionUiMode"))
1666    }
1667}