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                _ => <dyn Visitor>::ignore(),
378            })
379        }
380
381        fn deser_default() -> Self {
382            Self {
383                adaptive_pricing: Deserialize::default(),
384                after_expiration: Deserialize::default(),
385                allow_promotion_codes: Deserialize::default(),
386                amount_subtotal: Deserialize::default(),
387                amount_total: Deserialize::default(),
388                automatic_tax: Deserialize::default(),
389                billing_address_collection: Deserialize::default(),
390                branding_settings: Deserialize::default(),
391                cancel_url: Deserialize::default(),
392                client_reference_id: Deserialize::default(),
393                client_secret: Deserialize::default(),
394                collected_information: Deserialize::default(),
395                consent: Deserialize::default(),
396                consent_collection: Deserialize::default(),
397                created: Deserialize::default(),
398                currency: Deserialize::default(),
399                currency_conversion: Deserialize::default(),
400                custom_fields: Deserialize::default(),
401                custom_text: Deserialize::default(),
402                customer: Deserialize::default(),
403                customer_creation: Deserialize::default(),
404                customer_details: Deserialize::default(),
405                customer_email: Deserialize::default(),
406                discounts: Deserialize::default(),
407                excluded_payment_method_types: Deserialize::default(),
408                expires_at: Deserialize::default(),
409                id: Deserialize::default(),
410                invoice: Deserialize::default(),
411                invoice_creation: Deserialize::default(),
412                line_items: Deserialize::default(),
413                livemode: Deserialize::default(),
414                locale: Deserialize::default(),
415                metadata: Deserialize::default(),
416                mode: Deserialize::default(),
417                name_collection: Deserialize::default(),
418                optional_items: Deserialize::default(),
419                origin_context: Deserialize::default(),
420                payment_intent: Deserialize::default(),
421                payment_link: Deserialize::default(),
422                payment_method_collection: Deserialize::default(),
423                payment_method_configuration_details: Deserialize::default(),
424                payment_method_options: Deserialize::default(),
425                payment_method_types: Deserialize::default(),
426                payment_status: Deserialize::default(),
427                permissions: Deserialize::default(),
428                phone_number_collection: Deserialize::default(),
429                presentment_details: Deserialize::default(),
430                recovered_from: Deserialize::default(),
431                redirect_on_completion: Deserialize::default(),
432                return_url: Deserialize::default(),
433                saved_payment_method_options: Deserialize::default(),
434                setup_intent: Deserialize::default(),
435                shipping_address_collection: Deserialize::default(),
436                shipping_cost: Deserialize::default(),
437                shipping_options: Deserialize::default(),
438                status: Deserialize::default(),
439                submit_type: Deserialize::default(),
440                subscription: Deserialize::default(),
441                success_url: Deserialize::default(),
442                tax_id_collection: Deserialize::default(),
443                total_details: Deserialize::default(),
444                ui_mode: Deserialize::default(),
445                url: Deserialize::default(),
446                wallet_options: Deserialize::default(),
447            }
448        }
449
450        fn take_out(&mut self) -> Option<Self::Out> {
451            let (
452                Some(adaptive_pricing),
453                Some(after_expiration),
454                Some(allow_promotion_codes),
455                Some(amount_subtotal),
456                Some(amount_total),
457                Some(automatic_tax),
458                Some(billing_address_collection),
459                Some(branding_settings),
460                Some(cancel_url),
461                Some(client_reference_id),
462                Some(client_secret),
463                Some(collected_information),
464                Some(consent),
465                Some(consent_collection),
466                Some(created),
467                Some(currency),
468                Some(currency_conversion),
469                Some(custom_fields),
470                Some(custom_text),
471                Some(customer),
472                Some(customer_creation),
473                Some(customer_details),
474                Some(customer_email),
475                Some(discounts),
476                Some(excluded_payment_method_types),
477                Some(expires_at),
478                Some(id),
479                Some(invoice),
480                Some(invoice_creation),
481                Some(line_items),
482                Some(livemode),
483                Some(locale),
484                Some(metadata),
485                Some(mode),
486                Some(name_collection),
487                Some(optional_items),
488                Some(origin_context),
489                Some(payment_intent),
490                Some(payment_link),
491                Some(payment_method_collection),
492                Some(payment_method_configuration_details),
493                Some(payment_method_options),
494                Some(payment_method_types),
495                Some(payment_status),
496                Some(permissions),
497                Some(phone_number_collection),
498                Some(presentment_details),
499                Some(recovered_from),
500                Some(redirect_on_completion),
501                Some(return_url),
502                Some(saved_payment_method_options),
503                Some(setup_intent),
504                Some(shipping_address_collection),
505                Some(shipping_cost),
506                Some(shipping_options),
507                Some(status),
508                Some(submit_type),
509                Some(subscription),
510                Some(success_url),
511                Some(tax_id_collection),
512                Some(total_details),
513                Some(ui_mode),
514                Some(url),
515                Some(wallet_options),
516            ) = (
517                self.adaptive_pricing,
518                self.after_expiration.take(),
519                self.allow_promotion_codes,
520                self.amount_subtotal,
521                self.amount_total,
522                self.automatic_tax.take(),
523                self.billing_address_collection,
524                self.branding_settings.take(),
525                self.cancel_url.take(),
526                self.client_reference_id.take(),
527                self.client_secret.take(),
528                self.collected_information.take(),
529                self.consent,
530                self.consent_collection,
531                self.created,
532                self.currency.take(),
533                self.currency_conversion.take(),
534                self.custom_fields.take(),
535                self.custom_text.take(),
536                self.customer.take(),
537                self.customer_creation,
538                self.customer_details.take(),
539                self.customer_email.take(),
540                self.discounts.take(),
541                self.excluded_payment_method_types.take(),
542                self.expires_at,
543                self.id.take(),
544                self.invoice.take(),
545                self.invoice_creation.take(),
546                self.line_items.take(),
547                self.livemode,
548                self.locale.take(),
549                self.metadata.take(),
550                self.mode,
551                self.name_collection,
552                self.optional_items.take(),
553                self.origin_context,
554                self.payment_intent.take(),
555                self.payment_link.take(),
556                self.payment_method_collection,
557                self.payment_method_configuration_details.take(),
558                self.payment_method_options.take(),
559                self.payment_method_types.take(),
560                self.payment_status,
561                self.permissions,
562                self.phone_number_collection,
563                self.presentment_details.take(),
564                self.recovered_from.take(),
565                self.redirect_on_completion,
566                self.return_url.take(),
567                self.saved_payment_method_options.take(),
568                self.setup_intent.take(),
569                self.shipping_address_collection.take(),
570                self.shipping_cost.take(),
571                self.shipping_options.take(),
572                self.status,
573                self.submit_type,
574                self.subscription.take(),
575                self.success_url.take(),
576                self.tax_id_collection,
577                self.total_details.take(),
578                self.ui_mode,
579                self.url.take(),
580                self.wallet_options,
581            )
582            else {
583                return None;
584            };
585            Some(Self::Out {
586                adaptive_pricing,
587                after_expiration,
588                allow_promotion_codes,
589                amount_subtotal,
590                amount_total,
591                automatic_tax,
592                billing_address_collection,
593                branding_settings,
594                cancel_url,
595                client_reference_id,
596                client_secret,
597                collected_information,
598                consent,
599                consent_collection,
600                created,
601                currency,
602                currency_conversion,
603                custom_fields,
604                custom_text,
605                customer,
606                customer_creation,
607                customer_details,
608                customer_email,
609                discounts,
610                excluded_payment_method_types,
611                expires_at,
612                id,
613                invoice,
614                invoice_creation,
615                line_items,
616                livemode,
617                locale,
618                metadata,
619                mode,
620                name_collection,
621                optional_items,
622                origin_context,
623                payment_intent,
624                payment_link,
625                payment_method_collection,
626                payment_method_configuration_details,
627                payment_method_options,
628                payment_method_types,
629                payment_status,
630                permissions,
631                phone_number_collection,
632                presentment_details,
633                recovered_from,
634                redirect_on_completion,
635                return_url,
636                saved_payment_method_options,
637                setup_intent,
638                shipping_address_collection,
639                shipping_cost,
640                shipping_options,
641                status,
642                submit_type,
643                subscription,
644                success_url,
645                tax_id_collection,
646                total_details,
647                ui_mode,
648                url,
649                wallet_options,
650            })
651        }
652    }
653
654    impl Map for Builder<'_> {
655        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
656            self.builder.key(k)
657        }
658
659        fn finish(&mut self) -> Result<()> {
660            *self.out = self.builder.take_out();
661            Ok(())
662        }
663    }
664
665    impl ObjectDeser for CheckoutSession {
666        type Builder = CheckoutSessionBuilder;
667    }
668
669    impl FromValueOpt for CheckoutSession {
670        fn from_value(v: Value) -> Option<Self> {
671            let Value::Object(obj) = v else {
672                return None;
673            };
674            let mut b = CheckoutSessionBuilder::deser_default();
675            for (k, v) in obj {
676                match k.as_str() {
677                    "adaptive_pricing" => b.adaptive_pricing = FromValueOpt::from_value(v),
678                    "after_expiration" => b.after_expiration = FromValueOpt::from_value(v),
679                    "allow_promotion_codes" => {
680                        b.allow_promotion_codes = FromValueOpt::from_value(v)
681                    }
682                    "amount_subtotal" => b.amount_subtotal = FromValueOpt::from_value(v),
683                    "amount_total" => b.amount_total = FromValueOpt::from_value(v),
684                    "automatic_tax" => b.automatic_tax = FromValueOpt::from_value(v),
685                    "billing_address_collection" => {
686                        b.billing_address_collection = FromValueOpt::from_value(v)
687                    }
688                    "branding_settings" => b.branding_settings = FromValueOpt::from_value(v),
689                    "cancel_url" => b.cancel_url = FromValueOpt::from_value(v),
690                    "client_reference_id" => b.client_reference_id = FromValueOpt::from_value(v),
691                    "client_secret" => b.client_secret = FromValueOpt::from_value(v),
692                    "collected_information" => {
693                        b.collected_information = FromValueOpt::from_value(v)
694                    }
695                    "consent" => b.consent = FromValueOpt::from_value(v),
696                    "consent_collection" => b.consent_collection = FromValueOpt::from_value(v),
697                    "created" => b.created = FromValueOpt::from_value(v),
698                    "currency" => b.currency = FromValueOpt::from_value(v),
699                    "currency_conversion" => b.currency_conversion = FromValueOpt::from_value(v),
700                    "custom_fields" => b.custom_fields = FromValueOpt::from_value(v),
701                    "custom_text" => b.custom_text = FromValueOpt::from_value(v),
702                    "customer" => b.customer = FromValueOpt::from_value(v),
703                    "customer_creation" => b.customer_creation = FromValueOpt::from_value(v),
704                    "customer_details" => b.customer_details = FromValueOpt::from_value(v),
705                    "customer_email" => b.customer_email = FromValueOpt::from_value(v),
706                    "discounts" => b.discounts = FromValueOpt::from_value(v),
707                    "excluded_payment_method_types" => {
708                        b.excluded_payment_method_types = FromValueOpt::from_value(v)
709                    }
710                    "expires_at" => b.expires_at = FromValueOpt::from_value(v),
711                    "id" => b.id = FromValueOpt::from_value(v),
712                    "invoice" => b.invoice = FromValueOpt::from_value(v),
713                    "invoice_creation" => b.invoice_creation = FromValueOpt::from_value(v),
714                    "line_items" => b.line_items = FromValueOpt::from_value(v),
715                    "livemode" => b.livemode = FromValueOpt::from_value(v),
716                    "locale" => b.locale = FromValueOpt::from_value(v),
717                    "metadata" => b.metadata = FromValueOpt::from_value(v),
718                    "mode" => b.mode = FromValueOpt::from_value(v),
719                    "name_collection" => b.name_collection = FromValueOpt::from_value(v),
720                    "optional_items" => b.optional_items = FromValueOpt::from_value(v),
721                    "origin_context" => b.origin_context = FromValueOpt::from_value(v),
722                    "payment_intent" => b.payment_intent = FromValueOpt::from_value(v),
723                    "payment_link" => b.payment_link = FromValueOpt::from_value(v),
724                    "payment_method_collection" => {
725                        b.payment_method_collection = FromValueOpt::from_value(v)
726                    }
727                    "payment_method_configuration_details" => {
728                        b.payment_method_configuration_details = FromValueOpt::from_value(v)
729                    }
730                    "payment_method_options" => {
731                        b.payment_method_options = FromValueOpt::from_value(v)
732                    }
733                    "payment_method_types" => b.payment_method_types = FromValueOpt::from_value(v),
734                    "payment_status" => b.payment_status = FromValueOpt::from_value(v),
735                    "permissions" => b.permissions = FromValueOpt::from_value(v),
736                    "phone_number_collection" => {
737                        b.phone_number_collection = FromValueOpt::from_value(v)
738                    }
739                    "presentment_details" => b.presentment_details = FromValueOpt::from_value(v),
740                    "recovered_from" => b.recovered_from = FromValueOpt::from_value(v),
741                    "redirect_on_completion" => {
742                        b.redirect_on_completion = FromValueOpt::from_value(v)
743                    }
744                    "return_url" => b.return_url = FromValueOpt::from_value(v),
745                    "saved_payment_method_options" => {
746                        b.saved_payment_method_options = FromValueOpt::from_value(v)
747                    }
748                    "setup_intent" => b.setup_intent = FromValueOpt::from_value(v),
749                    "shipping_address_collection" => {
750                        b.shipping_address_collection = FromValueOpt::from_value(v)
751                    }
752                    "shipping_cost" => b.shipping_cost = FromValueOpt::from_value(v),
753                    "shipping_options" => b.shipping_options = FromValueOpt::from_value(v),
754                    "status" => b.status = FromValueOpt::from_value(v),
755                    "submit_type" => b.submit_type = FromValueOpt::from_value(v),
756                    "subscription" => b.subscription = FromValueOpt::from_value(v),
757                    "success_url" => b.success_url = FromValueOpt::from_value(v),
758                    "tax_id_collection" => b.tax_id_collection = FromValueOpt::from_value(v),
759                    "total_details" => b.total_details = FromValueOpt::from_value(v),
760                    "ui_mode" => b.ui_mode = FromValueOpt::from_value(v),
761                    "url" => b.url = FromValueOpt::from_value(v),
762                    "wallet_options" => b.wallet_options = FromValueOpt::from_value(v),
763                    _ => {}
764                }
765            }
766            b.take_out()
767        }
768    }
769};
770#[cfg(feature = "serialize")]
771impl serde::Serialize for CheckoutSession {
772    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
773        use serde::ser::SerializeStruct;
774        let mut s = s.serialize_struct("CheckoutSession", 65)?;
775        s.serialize_field("adaptive_pricing", &self.adaptive_pricing)?;
776        s.serialize_field("after_expiration", &self.after_expiration)?;
777        s.serialize_field("allow_promotion_codes", &self.allow_promotion_codes)?;
778        s.serialize_field("amount_subtotal", &self.amount_subtotal)?;
779        s.serialize_field("amount_total", &self.amount_total)?;
780        s.serialize_field("automatic_tax", &self.automatic_tax)?;
781        s.serialize_field("billing_address_collection", &self.billing_address_collection)?;
782        s.serialize_field("branding_settings", &self.branding_settings)?;
783        s.serialize_field("cancel_url", &self.cancel_url)?;
784        s.serialize_field("client_reference_id", &self.client_reference_id)?;
785        s.serialize_field("client_secret", &self.client_secret)?;
786        s.serialize_field("collected_information", &self.collected_information)?;
787        s.serialize_field("consent", &self.consent)?;
788        s.serialize_field("consent_collection", &self.consent_collection)?;
789        s.serialize_field("created", &self.created)?;
790        s.serialize_field("currency", &self.currency)?;
791        s.serialize_field("currency_conversion", &self.currency_conversion)?;
792        s.serialize_field("custom_fields", &self.custom_fields)?;
793        s.serialize_field("custom_text", &self.custom_text)?;
794        s.serialize_field("customer", &self.customer)?;
795        s.serialize_field("customer_creation", &self.customer_creation)?;
796        s.serialize_field("customer_details", &self.customer_details)?;
797        s.serialize_field("customer_email", &self.customer_email)?;
798        s.serialize_field("discounts", &self.discounts)?;
799        s.serialize_field("excluded_payment_method_types", &self.excluded_payment_method_types)?;
800        s.serialize_field("expires_at", &self.expires_at)?;
801        s.serialize_field("id", &self.id)?;
802        s.serialize_field("invoice", &self.invoice)?;
803        s.serialize_field("invoice_creation", &self.invoice_creation)?;
804        s.serialize_field("line_items", &self.line_items)?;
805        s.serialize_field("livemode", &self.livemode)?;
806        s.serialize_field("locale", &self.locale)?;
807        s.serialize_field("metadata", &self.metadata)?;
808        s.serialize_field("mode", &self.mode)?;
809        s.serialize_field("name_collection", &self.name_collection)?;
810        s.serialize_field("optional_items", &self.optional_items)?;
811        s.serialize_field("origin_context", &self.origin_context)?;
812        s.serialize_field("payment_intent", &self.payment_intent)?;
813        s.serialize_field("payment_link", &self.payment_link)?;
814        s.serialize_field("payment_method_collection", &self.payment_method_collection)?;
815        s.serialize_field(
816            "payment_method_configuration_details",
817            &self.payment_method_configuration_details,
818        )?;
819        s.serialize_field("payment_method_options", &self.payment_method_options)?;
820        s.serialize_field("payment_method_types", &self.payment_method_types)?;
821        s.serialize_field("payment_status", &self.payment_status)?;
822        s.serialize_field("permissions", &self.permissions)?;
823        s.serialize_field("phone_number_collection", &self.phone_number_collection)?;
824        s.serialize_field("presentment_details", &self.presentment_details)?;
825        s.serialize_field("recovered_from", &self.recovered_from)?;
826        s.serialize_field("redirect_on_completion", &self.redirect_on_completion)?;
827        s.serialize_field("return_url", &self.return_url)?;
828        s.serialize_field("saved_payment_method_options", &self.saved_payment_method_options)?;
829        s.serialize_field("setup_intent", &self.setup_intent)?;
830        s.serialize_field("shipping_address_collection", &self.shipping_address_collection)?;
831        s.serialize_field("shipping_cost", &self.shipping_cost)?;
832        s.serialize_field("shipping_options", &self.shipping_options)?;
833        s.serialize_field("status", &self.status)?;
834        s.serialize_field("submit_type", &self.submit_type)?;
835        s.serialize_field("subscription", &self.subscription)?;
836        s.serialize_field("success_url", &self.success_url)?;
837        s.serialize_field("tax_id_collection", &self.tax_id_collection)?;
838        s.serialize_field("total_details", &self.total_details)?;
839        s.serialize_field("ui_mode", &self.ui_mode)?;
840        s.serialize_field("url", &self.url)?;
841        s.serialize_field("wallet_options", &self.wallet_options)?;
842
843        s.serialize_field("object", "checkout.session")?;
844        s.end()
845    }
846}
847/// Configure whether a Checkout Session creates a Customer when the Checkout Session completes.
848#[derive(Copy, Clone, Eq, PartialEq)]
849pub enum CheckoutSessionCustomerCreation {
850    Always,
851    IfRequired,
852}
853impl CheckoutSessionCustomerCreation {
854    pub fn as_str(self) -> &'static str {
855        use CheckoutSessionCustomerCreation::*;
856        match self {
857            Always => "always",
858            IfRequired => "if_required",
859        }
860    }
861}
862
863impl std::str::FromStr for CheckoutSessionCustomerCreation {
864    type Err = stripe_types::StripeParseError;
865    fn from_str(s: &str) -> Result<Self, Self::Err> {
866        use CheckoutSessionCustomerCreation::*;
867        match s {
868            "always" => Ok(Always),
869            "if_required" => Ok(IfRequired),
870            _ => Err(stripe_types::StripeParseError),
871        }
872    }
873}
874impl std::fmt::Display for CheckoutSessionCustomerCreation {
875    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
876        f.write_str(self.as_str())
877    }
878}
879
880impl std::fmt::Debug for CheckoutSessionCustomerCreation {
881    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
882        f.write_str(self.as_str())
883    }
884}
885#[cfg(feature = "serialize")]
886impl serde::Serialize for CheckoutSessionCustomerCreation {
887    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
888    where
889        S: serde::Serializer,
890    {
891        serializer.serialize_str(self.as_str())
892    }
893}
894impl miniserde::Deserialize for CheckoutSessionCustomerCreation {
895    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
896        crate::Place::new(out)
897    }
898}
899
900impl miniserde::de::Visitor for crate::Place<CheckoutSessionCustomerCreation> {
901    fn string(&mut self, s: &str) -> miniserde::Result<()> {
902        use std::str::FromStr;
903        self.out =
904            Some(CheckoutSessionCustomerCreation::from_str(s).map_err(|_| miniserde::Error)?);
905        Ok(())
906    }
907}
908
909stripe_types::impl_from_val_with_from_str!(CheckoutSessionCustomerCreation);
910#[cfg(feature = "deserialize")]
911impl<'de> serde::Deserialize<'de> for CheckoutSessionCustomerCreation {
912    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
913        use std::str::FromStr;
914        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
915        Self::from_str(&s).map_err(|_| {
916            serde::de::Error::custom("Unknown value for CheckoutSessionCustomerCreation")
917        })
918    }
919}
920/// Configure whether a Checkout Session should collect a payment method. Defaults to `always`.
921#[derive(Copy, Clone, Eq, PartialEq)]
922pub enum CheckoutSessionPaymentMethodCollection {
923    Always,
924    IfRequired,
925}
926impl CheckoutSessionPaymentMethodCollection {
927    pub fn as_str(self) -> &'static str {
928        use CheckoutSessionPaymentMethodCollection::*;
929        match self {
930            Always => "always",
931            IfRequired => "if_required",
932        }
933    }
934}
935
936impl std::str::FromStr for CheckoutSessionPaymentMethodCollection {
937    type Err = stripe_types::StripeParseError;
938    fn from_str(s: &str) -> Result<Self, Self::Err> {
939        use CheckoutSessionPaymentMethodCollection::*;
940        match s {
941            "always" => Ok(Always),
942            "if_required" => Ok(IfRequired),
943            _ => Err(stripe_types::StripeParseError),
944        }
945    }
946}
947impl std::fmt::Display for CheckoutSessionPaymentMethodCollection {
948    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
949        f.write_str(self.as_str())
950    }
951}
952
953impl std::fmt::Debug for CheckoutSessionPaymentMethodCollection {
954    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
955        f.write_str(self.as_str())
956    }
957}
958#[cfg(feature = "serialize")]
959impl serde::Serialize for CheckoutSessionPaymentMethodCollection {
960    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
961    where
962        S: serde::Serializer,
963    {
964        serializer.serialize_str(self.as_str())
965    }
966}
967impl miniserde::Deserialize for CheckoutSessionPaymentMethodCollection {
968    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
969        crate::Place::new(out)
970    }
971}
972
973impl miniserde::de::Visitor for crate::Place<CheckoutSessionPaymentMethodCollection> {
974    fn string(&mut self, s: &str) -> miniserde::Result<()> {
975        use std::str::FromStr;
976        self.out = Some(
977            CheckoutSessionPaymentMethodCollection::from_str(s).map_err(|_| miniserde::Error)?,
978        );
979        Ok(())
980    }
981}
982
983stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentMethodCollection);
984#[cfg(feature = "deserialize")]
985impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentMethodCollection {
986    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
987        use std::str::FromStr;
988        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
989        Self::from_str(&s).map_err(|_| {
990            serde::de::Error::custom("Unknown value for CheckoutSessionPaymentMethodCollection")
991        })
992    }
993}
994/// The payment status of the Checkout Session, one of `paid`, `unpaid`, or `no_payment_required`.
995/// You can use this value to decide when to fulfill your customer's order.
996#[derive(Copy, Clone, Eq, PartialEq)]
997pub enum CheckoutSessionPaymentStatus {
998    NoPaymentRequired,
999    Paid,
1000    Unpaid,
1001}
1002impl CheckoutSessionPaymentStatus {
1003    pub fn as_str(self) -> &'static str {
1004        use CheckoutSessionPaymentStatus::*;
1005        match self {
1006            NoPaymentRequired => "no_payment_required",
1007            Paid => "paid",
1008            Unpaid => "unpaid",
1009        }
1010    }
1011}
1012
1013impl std::str::FromStr for CheckoutSessionPaymentStatus {
1014    type Err = stripe_types::StripeParseError;
1015    fn from_str(s: &str) -> Result<Self, Self::Err> {
1016        use CheckoutSessionPaymentStatus::*;
1017        match s {
1018            "no_payment_required" => Ok(NoPaymentRequired),
1019            "paid" => Ok(Paid),
1020            "unpaid" => Ok(Unpaid),
1021            _ => Err(stripe_types::StripeParseError),
1022        }
1023    }
1024}
1025impl std::fmt::Display for CheckoutSessionPaymentStatus {
1026    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1027        f.write_str(self.as_str())
1028    }
1029}
1030
1031impl std::fmt::Debug for CheckoutSessionPaymentStatus {
1032    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1033        f.write_str(self.as_str())
1034    }
1035}
1036#[cfg(feature = "serialize")]
1037impl serde::Serialize for CheckoutSessionPaymentStatus {
1038    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1039    where
1040        S: serde::Serializer,
1041    {
1042        serializer.serialize_str(self.as_str())
1043    }
1044}
1045impl miniserde::Deserialize for CheckoutSessionPaymentStatus {
1046    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1047        crate::Place::new(out)
1048    }
1049}
1050
1051impl miniserde::de::Visitor for crate::Place<CheckoutSessionPaymentStatus> {
1052    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1053        use std::str::FromStr;
1054        self.out = Some(CheckoutSessionPaymentStatus::from_str(s).map_err(|_| miniserde::Error)?);
1055        Ok(())
1056    }
1057}
1058
1059stripe_types::impl_from_val_with_from_str!(CheckoutSessionPaymentStatus);
1060#[cfg(feature = "deserialize")]
1061impl<'de> serde::Deserialize<'de> for CheckoutSessionPaymentStatus {
1062    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1063        use std::str::FromStr;
1064        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1065        Self::from_str(&s)
1066            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionPaymentStatus"))
1067    }
1068}
1069impl stripe_types::Object for CheckoutSession {
1070    type Id = stripe_shared::CheckoutSessionId;
1071    fn id(&self) -> &Self::Id {
1072        &self.id
1073    }
1074
1075    fn into_id(self) -> Self::Id {
1076        self.id
1077    }
1078}
1079stripe_types::def_id!(CheckoutSessionId);
1080#[derive(Copy, Clone, Eq, PartialEq)]
1081pub enum CheckoutSessionBillingAddressCollection {
1082    Auto,
1083    Required,
1084}
1085impl CheckoutSessionBillingAddressCollection {
1086    pub fn as_str(self) -> &'static str {
1087        use CheckoutSessionBillingAddressCollection::*;
1088        match self {
1089            Auto => "auto",
1090            Required => "required",
1091        }
1092    }
1093}
1094
1095impl std::str::FromStr for CheckoutSessionBillingAddressCollection {
1096    type Err = stripe_types::StripeParseError;
1097    fn from_str(s: &str) -> Result<Self, Self::Err> {
1098        use CheckoutSessionBillingAddressCollection::*;
1099        match s {
1100            "auto" => Ok(Auto),
1101            "required" => Ok(Required),
1102            _ => Err(stripe_types::StripeParseError),
1103        }
1104    }
1105}
1106impl std::fmt::Display for CheckoutSessionBillingAddressCollection {
1107    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1108        f.write_str(self.as_str())
1109    }
1110}
1111
1112impl std::fmt::Debug for CheckoutSessionBillingAddressCollection {
1113    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1114        f.write_str(self.as_str())
1115    }
1116}
1117impl serde::Serialize for CheckoutSessionBillingAddressCollection {
1118    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1119    where
1120        S: serde::Serializer,
1121    {
1122        serializer.serialize_str(self.as_str())
1123    }
1124}
1125impl miniserde::Deserialize for CheckoutSessionBillingAddressCollection {
1126    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1127        crate::Place::new(out)
1128    }
1129}
1130
1131impl miniserde::de::Visitor for crate::Place<CheckoutSessionBillingAddressCollection> {
1132    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1133        use std::str::FromStr;
1134        self.out = Some(
1135            CheckoutSessionBillingAddressCollection::from_str(s).map_err(|_| miniserde::Error)?,
1136        );
1137        Ok(())
1138    }
1139}
1140
1141stripe_types::impl_from_val_with_from_str!(CheckoutSessionBillingAddressCollection);
1142#[cfg(feature = "deserialize")]
1143impl<'de> serde::Deserialize<'de> for CheckoutSessionBillingAddressCollection {
1144    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1145        use std::str::FromStr;
1146        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1147        Self::from_str(&s).map_err(|_| {
1148            serde::de::Error::custom("Unknown value for CheckoutSessionBillingAddressCollection")
1149        })
1150    }
1151}
1152#[derive(Clone, Eq, PartialEq)]
1153#[non_exhaustive]
1154pub enum CheckoutSessionLocale {
1155    Auto,
1156    Bg,
1157    Cs,
1158    Da,
1159    De,
1160    El,
1161    En,
1162    EnMinusGb,
1163    Es,
1164    EsMinus419,
1165    Et,
1166    Fi,
1167    Fil,
1168    Fr,
1169    FrMinusCa,
1170    Hr,
1171    Hu,
1172    Id,
1173    It,
1174    Ja,
1175    Ko,
1176    Lt,
1177    Lv,
1178    Ms,
1179    Mt,
1180    Nb,
1181    Nl,
1182    Pl,
1183    Pt,
1184    PtMinusBr,
1185    Ro,
1186    Ru,
1187    Sk,
1188    Sl,
1189    Sv,
1190    Th,
1191    Tr,
1192    Vi,
1193    Zh,
1194    ZhMinusHk,
1195    ZhMinusTw,
1196    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1197    Unknown(String),
1198}
1199impl CheckoutSessionLocale {
1200    pub fn as_str(&self) -> &str {
1201        use CheckoutSessionLocale::*;
1202        match self {
1203            Auto => "auto",
1204            Bg => "bg",
1205            Cs => "cs",
1206            Da => "da",
1207            De => "de",
1208            El => "el",
1209            En => "en",
1210            EnMinusGb => "en-GB",
1211            Es => "es",
1212            EsMinus419 => "es-419",
1213            Et => "et",
1214            Fi => "fi",
1215            Fil => "fil",
1216            Fr => "fr",
1217            FrMinusCa => "fr-CA",
1218            Hr => "hr",
1219            Hu => "hu",
1220            Id => "id",
1221            It => "it",
1222            Ja => "ja",
1223            Ko => "ko",
1224            Lt => "lt",
1225            Lv => "lv",
1226            Ms => "ms",
1227            Mt => "mt",
1228            Nb => "nb",
1229            Nl => "nl",
1230            Pl => "pl",
1231            Pt => "pt",
1232            PtMinusBr => "pt-BR",
1233            Ro => "ro",
1234            Ru => "ru",
1235            Sk => "sk",
1236            Sl => "sl",
1237            Sv => "sv",
1238            Th => "th",
1239            Tr => "tr",
1240            Vi => "vi",
1241            Zh => "zh",
1242            ZhMinusHk => "zh-HK",
1243            ZhMinusTw => "zh-TW",
1244            Unknown(v) => v,
1245        }
1246    }
1247}
1248
1249impl std::str::FromStr for CheckoutSessionLocale {
1250    type Err = std::convert::Infallible;
1251    fn from_str(s: &str) -> Result<Self, Self::Err> {
1252        use CheckoutSessionLocale::*;
1253        match s {
1254            "auto" => Ok(Auto),
1255            "bg" => Ok(Bg),
1256            "cs" => Ok(Cs),
1257            "da" => Ok(Da),
1258            "de" => Ok(De),
1259            "el" => Ok(El),
1260            "en" => Ok(En),
1261            "en-GB" => Ok(EnMinusGb),
1262            "es" => Ok(Es),
1263            "es-419" => Ok(EsMinus419),
1264            "et" => Ok(Et),
1265            "fi" => Ok(Fi),
1266            "fil" => Ok(Fil),
1267            "fr" => Ok(Fr),
1268            "fr-CA" => Ok(FrMinusCa),
1269            "hr" => Ok(Hr),
1270            "hu" => Ok(Hu),
1271            "id" => Ok(Id),
1272            "it" => Ok(It),
1273            "ja" => Ok(Ja),
1274            "ko" => Ok(Ko),
1275            "lt" => Ok(Lt),
1276            "lv" => Ok(Lv),
1277            "ms" => Ok(Ms),
1278            "mt" => Ok(Mt),
1279            "nb" => Ok(Nb),
1280            "nl" => Ok(Nl),
1281            "pl" => Ok(Pl),
1282            "pt" => Ok(Pt),
1283            "pt-BR" => Ok(PtMinusBr),
1284            "ro" => Ok(Ro),
1285            "ru" => Ok(Ru),
1286            "sk" => Ok(Sk),
1287            "sl" => Ok(Sl),
1288            "sv" => Ok(Sv),
1289            "th" => Ok(Th),
1290            "tr" => Ok(Tr),
1291            "vi" => Ok(Vi),
1292            "zh" => Ok(Zh),
1293            "zh-HK" => Ok(ZhMinusHk),
1294            "zh-TW" => Ok(ZhMinusTw),
1295            v => Ok(Unknown(v.to_owned())),
1296        }
1297    }
1298}
1299impl std::fmt::Display for CheckoutSessionLocale {
1300    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1301        f.write_str(self.as_str())
1302    }
1303}
1304
1305impl std::fmt::Debug for CheckoutSessionLocale {
1306    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1307        f.write_str(self.as_str())
1308    }
1309}
1310impl serde::Serialize for CheckoutSessionLocale {
1311    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1312    where
1313        S: serde::Serializer,
1314    {
1315        serializer.serialize_str(self.as_str())
1316    }
1317}
1318impl miniserde::Deserialize for CheckoutSessionLocale {
1319    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1320        crate::Place::new(out)
1321    }
1322}
1323
1324impl miniserde::de::Visitor for crate::Place<CheckoutSessionLocale> {
1325    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1326        use std::str::FromStr;
1327        self.out = Some(CheckoutSessionLocale::from_str(s).unwrap());
1328        Ok(())
1329    }
1330}
1331
1332stripe_types::impl_from_val_with_from_str!(CheckoutSessionLocale);
1333#[cfg(feature = "deserialize")]
1334impl<'de> serde::Deserialize<'de> for CheckoutSessionLocale {
1335    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1336        use std::str::FromStr;
1337        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1338        Ok(Self::from_str(&s).unwrap())
1339    }
1340}
1341#[derive(Copy, Clone, Eq, PartialEq)]
1342pub enum CheckoutSessionMode {
1343    Payment,
1344    Setup,
1345    Subscription,
1346}
1347impl CheckoutSessionMode {
1348    pub fn as_str(self) -> &'static str {
1349        use CheckoutSessionMode::*;
1350        match self {
1351            Payment => "payment",
1352            Setup => "setup",
1353            Subscription => "subscription",
1354        }
1355    }
1356}
1357
1358impl std::str::FromStr for CheckoutSessionMode {
1359    type Err = stripe_types::StripeParseError;
1360    fn from_str(s: &str) -> Result<Self, Self::Err> {
1361        use CheckoutSessionMode::*;
1362        match s {
1363            "payment" => Ok(Payment),
1364            "setup" => Ok(Setup),
1365            "subscription" => Ok(Subscription),
1366            _ => Err(stripe_types::StripeParseError),
1367        }
1368    }
1369}
1370impl std::fmt::Display for CheckoutSessionMode {
1371    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1372        f.write_str(self.as_str())
1373    }
1374}
1375
1376impl std::fmt::Debug for CheckoutSessionMode {
1377    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1378        f.write_str(self.as_str())
1379    }
1380}
1381impl serde::Serialize for CheckoutSessionMode {
1382    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1383    where
1384        S: serde::Serializer,
1385    {
1386        serializer.serialize_str(self.as_str())
1387    }
1388}
1389impl miniserde::Deserialize for CheckoutSessionMode {
1390    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1391        crate::Place::new(out)
1392    }
1393}
1394
1395impl miniserde::de::Visitor for crate::Place<CheckoutSessionMode> {
1396    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1397        use std::str::FromStr;
1398        self.out = Some(CheckoutSessionMode::from_str(s).map_err(|_| miniserde::Error)?);
1399        Ok(())
1400    }
1401}
1402
1403stripe_types::impl_from_val_with_from_str!(CheckoutSessionMode);
1404#[cfg(feature = "deserialize")]
1405impl<'de> serde::Deserialize<'de> for CheckoutSessionMode {
1406    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1407        use std::str::FromStr;
1408        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1409        Self::from_str(&s)
1410            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionMode"))
1411    }
1412}
1413#[derive(Copy, Clone, Eq, PartialEq)]
1414pub enum CheckoutSessionOriginContext {
1415    MobileApp,
1416    Web,
1417}
1418impl CheckoutSessionOriginContext {
1419    pub fn as_str(self) -> &'static str {
1420        use CheckoutSessionOriginContext::*;
1421        match self {
1422            MobileApp => "mobile_app",
1423            Web => "web",
1424        }
1425    }
1426}
1427
1428impl std::str::FromStr for CheckoutSessionOriginContext {
1429    type Err = stripe_types::StripeParseError;
1430    fn from_str(s: &str) -> Result<Self, Self::Err> {
1431        use CheckoutSessionOriginContext::*;
1432        match s {
1433            "mobile_app" => Ok(MobileApp),
1434            "web" => Ok(Web),
1435            _ => Err(stripe_types::StripeParseError),
1436        }
1437    }
1438}
1439impl std::fmt::Display for CheckoutSessionOriginContext {
1440    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1441        f.write_str(self.as_str())
1442    }
1443}
1444
1445impl std::fmt::Debug for CheckoutSessionOriginContext {
1446    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1447        f.write_str(self.as_str())
1448    }
1449}
1450impl serde::Serialize for CheckoutSessionOriginContext {
1451    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1452    where
1453        S: serde::Serializer,
1454    {
1455        serializer.serialize_str(self.as_str())
1456    }
1457}
1458impl miniserde::Deserialize for CheckoutSessionOriginContext {
1459    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1460        crate::Place::new(out)
1461    }
1462}
1463
1464impl miniserde::de::Visitor for crate::Place<CheckoutSessionOriginContext> {
1465    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1466        use std::str::FromStr;
1467        self.out = Some(CheckoutSessionOriginContext::from_str(s).map_err(|_| miniserde::Error)?);
1468        Ok(())
1469    }
1470}
1471
1472stripe_types::impl_from_val_with_from_str!(CheckoutSessionOriginContext);
1473#[cfg(feature = "deserialize")]
1474impl<'de> serde::Deserialize<'de> for CheckoutSessionOriginContext {
1475    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1476        use std::str::FromStr;
1477        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1478        Self::from_str(&s)
1479            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionOriginContext"))
1480    }
1481}
1482#[derive(Copy, Clone, Eq, PartialEq)]
1483pub enum CheckoutSessionRedirectOnCompletion {
1484    Always,
1485    IfRequired,
1486    Never,
1487}
1488impl CheckoutSessionRedirectOnCompletion {
1489    pub fn as_str(self) -> &'static str {
1490        use CheckoutSessionRedirectOnCompletion::*;
1491        match self {
1492            Always => "always",
1493            IfRequired => "if_required",
1494            Never => "never",
1495        }
1496    }
1497}
1498
1499impl std::str::FromStr for CheckoutSessionRedirectOnCompletion {
1500    type Err = stripe_types::StripeParseError;
1501    fn from_str(s: &str) -> Result<Self, Self::Err> {
1502        use CheckoutSessionRedirectOnCompletion::*;
1503        match s {
1504            "always" => Ok(Always),
1505            "if_required" => Ok(IfRequired),
1506            "never" => Ok(Never),
1507            _ => Err(stripe_types::StripeParseError),
1508        }
1509    }
1510}
1511impl std::fmt::Display for CheckoutSessionRedirectOnCompletion {
1512    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1513        f.write_str(self.as_str())
1514    }
1515}
1516
1517impl std::fmt::Debug for CheckoutSessionRedirectOnCompletion {
1518    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1519        f.write_str(self.as_str())
1520    }
1521}
1522impl serde::Serialize for CheckoutSessionRedirectOnCompletion {
1523    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1524    where
1525        S: serde::Serializer,
1526    {
1527        serializer.serialize_str(self.as_str())
1528    }
1529}
1530impl miniserde::Deserialize for CheckoutSessionRedirectOnCompletion {
1531    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1532        crate::Place::new(out)
1533    }
1534}
1535
1536impl miniserde::de::Visitor for crate::Place<CheckoutSessionRedirectOnCompletion> {
1537    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1538        use std::str::FromStr;
1539        self.out =
1540            Some(CheckoutSessionRedirectOnCompletion::from_str(s).map_err(|_| miniserde::Error)?);
1541        Ok(())
1542    }
1543}
1544
1545stripe_types::impl_from_val_with_from_str!(CheckoutSessionRedirectOnCompletion);
1546#[cfg(feature = "deserialize")]
1547impl<'de> serde::Deserialize<'de> for CheckoutSessionRedirectOnCompletion {
1548    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1549        use std::str::FromStr;
1550        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1551        Self::from_str(&s).map_err(|_| {
1552            serde::de::Error::custom("Unknown value for CheckoutSessionRedirectOnCompletion")
1553        })
1554    }
1555}
1556#[derive(Copy, Clone, Eq, PartialEq)]
1557pub enum CheckoutSessionStatus {
1558    Complete,
1559    Expired,
1560    Open,
1561}
1562impl CheckoutSessionStatus {
1563    pub fn as_str(self) -> &'static str {
1564        use CheckoutSessionStatus::*;
1565        match self {
1566            Complete => "complete",
1567            Expired => "expired",
1568            Open => "open",
1569        }
1570    }
1571}
1572
1573impl std::str::FromStr for CheckoutSessionStatus {
1574    type Err = stripe_types::StripeParseError;
1575    fn from_str(s: &str) -> Result<Self, Self::Err> {
1576        use CheckoutSessionStatus::*;
1577        match s {
1578            "complete" => Ok(Complete),
1579            "expired" => Ok(Expired),
1580            "open" => Ok(Open),
1581            _ => Err(stripe_types::StripeParseError),
1582        }
1583    }
1584}
1585impl std::fmt::Display for CheckoutSessionStatus {
1586    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1587        f.write_str(self.as_str())
1588    }
1589}
1590
1591impl std::fmt::Debug for CheckoutSessionStatus {
1592    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1593        f.write_str(self.as_str())
1594    }
1595}
1596impl serde::Serialize for CheckoutSessionStatus {
1597    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1598    where
1599        S: serde::Serializer,
1600    {
1601        serializer.serialize_str(self.as_str())
1602    }
1603}
1604impl miniserde::Deserialize for CheckoutSessionStatus {
1605    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1606        crate::Place::new(out)
1607    }
1608}
1609
1610impl miniserde::de::Visitor for crate::Place<CheckoutSessionStatus> {
1611    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1612        use std::str::FromStr;
1613        self.out = Some(CheckoutSessionStatus::from_str(s).map_err(|_| miniserde::Error)?);
1614        Ok(())
1615    }
1616}
1617
1618stripe_types::impl_from_val_with_from_str!(CheckoutSessionStatus);
1619#[cfg(feature = "deserialize")]
1620impl<'de> serde::Deserialize<'de> for CheckoutSessionStatus {
1621    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1622        use std::str::FromStr;
1623        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1624        Self::from_str(&s)
1625            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionStatus"))
1626    }
1627}
1628#[derive(Copy, Clone, Eq, PartialEq)]
1629pub enum CheckoutSessionSubmitType {
1630    Auto,
1631    Book,
1632    Donate,
1633    Pay,
1634    Subscribe,
1635}
1636impl CheckoutSessionSubmitType {
1637    pub fn as_str(self) -> &'static str {
1638        use CheckoutSessionSubmitType::*;
1639        match self {
1640            Auto => "auto",
1641            Book => "book",
1642            Donate => "donate",
1643            Pay => "pay",
1644            Subscribe => "subscribe",
1645        }
1646    }
1647}
1648
1649impl std::str::FromStr for CheckoutSessionSubmitType {
1650    type Err = stripe_types::StripeParseError;
1651    fn from_str(s: &str) -> Result<Self, Self::Err> {
1652        use CheckoutSessionSubmitType::*;
1653        match s {
1654            "auto" => Ok(Auto),
1655            "book" => Ok(Book),
1656            "donate" => Ok(Donate),
1657            "pay" => Ok(Pay),
1658            "subscribe" => Ok(Subscribe),
1659            _ => Err(stripe_types::StripeParseError),
1660        }
1661    }
1662}
1663impl std::fmt::Display for CheckoutSessionSubmitType {
1664    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1665        f.write_str(self.as_str())
1666    }
1667}
1668
1669impl std::fmt::Debug for CheckoutSessionSubmitType {
1670    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1671        f.write_str(self.as_str())
1672    }
1673}
1674impl serde::Serialize for CheckoutSessionSubmitType {
1675    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1676    where
1677        S: serde::Serializer,
1678    {
1679        serializer.serialize_str(self.as_str())
1680    }
1681}
1682impl miniserde::Deserialize for CheckoutSessionSubmitType {
1683    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1684        crate::Place::new(out)
1685    }
1686}
1687
1688impl miniserde::de::Visitor for crate::Place<CheckoutSessionSubmitType> {
1689    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1690        use std::str::FromStr;
1691        self.out = Some(CheckoutSessionSubmitType::from_str(s).map_err(|_| miniserde::Error)?);
1692        Ok(())
1693    }
1694}
1695
1696stripe_types::impl_from_val_with_from_str!(CheckoutSessionSubmitType);
1697#[cfg(feature = "deserialize")]
1698impl<'de> serde::Deserialize<'de> for CheckoutSessionSubmitType {
1699    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1700        use std::str::FromStr;
1701        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1702        Self::from_str(&s)
1703            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionSubmitType"))
1704    }
1705}
1706#[derive(Copy, Clone, Eq, PartialEq)]
1707pub enum CheckoutSessionUiMode {
1708    Custom,
1709    Embedded,
1710    Hosted,
1711}
1712impl CheckoutSessionUiMode {
1713    pub fn as_str(self) -> &'static str {
1714        use CheckoutSessionUiMode::*;
1715        match self {
1716            Custom => "custom",
1717            Embedded => "embedded",
1718            Hosted => "hosted",
1719        }
1720    }
1721}
1722
1723impl std::str::FromStr for CheckoutSessionUiMode {
1724    type Err = stripe_types::StripeParseError;
1725    fn from_str(s: &str) -> Result<Self, Self::Err> {
1726        use CheckoutSessionUiMode::*;
1727        match s {
1728            "custom" => Ok(Custom),
1729            "embedded" => Ok(Embedded),
1730            "hosted" => Ok(Hosted),
1731            _ => Err(stripe_types::StripeParseError),
1732        }
1733    }
1734}
1735impl std::fmt::Display for CheckoutSessionUiMode {
1736    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1737        f.write_str(self.as_str())
1738    }
1739}
1740
1741impl std::fmt::Debug for CheckoutSessionUiMode {
1742    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1743        f.write_str(self.as_str())
1744    }
1745}
1746impl serde::Serialize for CheckoutSessionUiMode {
1747    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1748    where
1749        S: serde::Serializer,
1750    {
1751        serializer.serialize_str(self.as_str())
1752    }
1753}
1754impl miniserde::Deserialize for CheckoutSessionUiMode {
1755    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
1756        crate::Place::new(out)
1757    }
1758}
1759
1760impl miniserde::de::Visitor for crate::Place<CheckoutSessionUiMode> {
1761    fn string(&mut self, s: &str) -> miniserde::Result<()> {
1762        use std::str::FromStr;
1763        self.out = Some(CheckoutSessionUiMode::from_str(s).map_err(|_| miniserde::Error)?);
1764        Ok(())
1765    }
1766}
1767
1768stripe_types::impl_from_val_with_from_str!(CheckoutSessionUiMode);
1769#[cfg(feature = "deserialize")]
1770impl<'de> serde::Deserialize<'de> for CheckoutSessionUiMode {
1771    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1772        use std::str::FromStr;
1773        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1774        Self::from_str(&s)
1775            .map_err(|_| serde::de::Error::custom("Unknown value for CheckoutSessionUiMode"))
1776    }
1777}