Skip to main content

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