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