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