stripe_shared/
checkout_session.rs

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