stripe_shared/
subscription_schedule_phase_configuration.rs

1/// A phase describes the plans, coupon, and trialing status of a subscription for a predefined time period.
2#[derive(Clone, Debug)]
3#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
4#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
5pub struct SubscriptionSchedulePhaseConfiguration {
6    /// A list of prices and quantities that will generate invoice items appended to the next invoice for this phase.
7    pub add_invoice_items: Vec<stripe_shared::SubscriptionScheduleAddInvoiceItem>,
8    /// A non-negative decimal between 0 and 100, with at most two decimal places.
9    /// This represents the percentage of the subscription invoice total that will be transferred to the application owner's Stripe account during this phase of the schedule.
10    pub application_fee_percent: Option<f64>,
11    pub automatic_tax: Option<stripe_shared::SchedulesPhaseAutomaticTax>,
12    /// Possible values are `phase_start` or `automatic`.
13    /// If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase.
14    /// If `automatic` then the billing cycle anchor is automatically modified as needed when entering the phase.
15    /// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
16    pub billing_cycle_anchor: Option<SubscriptionSchedulePhaseConfigurationBillingCycleAnchor>,
17    /// Define thresholds at which an invoice will be sent, and the subscription advanced to a new billing period.
18    pub billing_thresholds: Option<stripe_shared::SubscriptionBillingThresholds>,
19    /// Either `charge_automatically`, or `send_invoice`.
20    /// When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer.
21    /// When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`.
22    pub collection_method: Option<SubscriptionSchedulePhaseConfigurationCollectionMethod>,
23    /// Three-letter [ISO currency code](https://www.iso.org/iso-4217-currency-codes.html), in lowercase.
24    /// Must be a [supported currency](https://stripe.com/docs/currencies).
25    pub currency: stripe_types::Currency,
26    /// ID of the default payment method for the subscription schedule.
27    /// It must belong to the customer associated with the subscription schedule.
28    /// If not set, invoices will use the default payment method in the customer's invoice settings.
29    pub default_payment_method: Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>,
30    /// The default tax rates to apply to the subscription during this phase of the subscription schedule.
31    pub default_tax_rates: Option<Vec<stripe_shared::TaxRate>>,
32    /// Subscription description, meant to be displayable to the customer.
33    /// Use this field to optionally store an explanation of the subscription for rendering in Stripe surfaces and certain local payment methods UIs.
34    pub description: Option<String>,
35    /// The stackable discounts that will be applied to the subscription on this phase.
36    /// Subscription item discounts are applied before subscription discounts.
37    pub discounts: Vec<stripe_shared::DiscountsResourceStackableDiscount>,
38    /// The end of this phase of the subscription schedule.
39    pub end_date: stripe_types::Timestamp,
40    /// The invoice settings applicable during this phase.
41    pub invoice_settings: Option<stripe_shared::InvoiceSettingSubscriptionSchedulePhaseSetting>,
42    /// Subscription items to configure the subscription to during this phase of the subscription schedule.
43    pub items: Vec<stripe_shared::SubscriptionScheduleConfigurationItem>,
44    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to a phase.
45    /// Metadata on a schedule's phase will update the underlying subscription's `metadata` when the phase is entered.
46    /// Updating the underlying subscription's `metadata` directly will not affect the current phase's `metadata`.
47    pub metadata: Option<std::collections::HashMap<String, String>>,
48    /// The account (if any) the charge was made on behalf of for charges associated with the schedule's subscription.
49    /// See the Connect documentation for details.
50    pub on_behalf_of: Option<stripe_types::Expandable<stripe_shared::Account>>,
51    /// When transitioning phases, controls how prorations are handled (if any).
52    /// Possible values are `create_prorations`, `none`, and `always_invoice`.
53    pub proration_behavior: SubscriptionSchedulePhaseConfigurationProrationBehavior,
54    /// The start of this phase of the subscription schedule.
55    pub start_date: stripe_types::Timestamp,
56    /// The account (if any) the associated subscription's payments will be attributed to for tax reporting, and where funds from each payment will be transferred to for each of the subscription's invoices.
57    pub transfer_data: Option<stripe_shared::SubscriptionTransferData>,
58    /// When the trial ends within the phase.
59    pub trial_end: Option<stripe_types::Timestamp>,
60}
61#[doc(hidden)]
62pub struct SubscriptionSchedulePhaseConfigurationBuilder {
63    add_invoice_items: Option<Vec<stripe_shared::SubscriptionScheduleAddInvoiceItem>>,
64    application_fee_percent: Option<Option<f64>>,
65    automatic_tax: Option<Option<stripe_shared::SchedulesPhaseAutomaticTax>>,
66    billing_cycle_anchor: Option<Option<SubscriptionSchedulePhaseConfigurationBillingCycleAnchor>>,
67    billing_thresholds: Option<Option<stripe_shared::SubscriptionBillingThresholds>>,
68    collection_method: Option<Option<SubscriptionSchedulePhaseConfigurationCollectionMethod>>,
69    currency: Option<stripe_types::Currency>,
70    default_payment_method: Option<Option<stripe_types::Expandable<stripe_shared::PaymentMethod>>>,
71    default_tax_rates: Option<Option<Vec<stripe_shared::TaxRate>>>,
72    description: Option<Option<String>>,
73    discounts: Option<Vec<stripe_shared::DiscountsResourceStackableDiscount>>,
74    end_date: Option<stripe_types::Timestamp>,
75    invoice_settings: Option<Option<stripe_shared::InvoiceSettingSubscriptionSchedulePhaseSetting>>,
76    items: Option<Vec<stripe_shared::SubscriptionScheduleConfigurationItem>>,
77    metadata: Option<Option<std::collections::HashMap<String, String>>>,
78    on_behalf_of: Option<Option<stripe_types::Expandable<stripe_shared::Account>>>,
79    proration_behavior: Option<SubscriptionSchedulePhaseConfigurationProrationBehavior>,
80    start_date: Option<stripe_types::Timestamp>,
81    transfer_data: Option<Option<stripe_shared::SubscriptionTransferData>>,
82    trial_end: Option<Option<stripe_types::Timestamp>>,
83}
84
85#[allow(
86    unused_variables,
87    irrefutable_let_patterns,
88    clippy::let_unit_value,
89    clippy::match_single_binding,
90    clippy::single_match
91)]
92const _: () = {
93    use miniserde::de::{Map, Visitor};
94    use miniserde::json::Value;
95    use miniserde::{Deserialize, Result, make_place};
96    use stripe_types::miniserde_helpers::FromValueOpt;
97    use stripe_types::{MapBuilder, ObjectDeser};
98
99    make_place!(Place);
100
101    impl Deserialize for SubscriptionSchedulePhaseConfiguration {
102        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
103            Place::new(out)
104        }
105    }
106
107    struct Builder<'a> {
108        out: &'a mut Option<SubscriptionSchedulePhaseConfiguration>,
109        builder: SubscriptionSchedulePhaseConfigurationBuilder,
110    }
111
112    impl Visitor for Place<SubscriptionSchedulePhaseConfiguration> {
113        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
114            Ok(Box::new(Builder {
115                out: &mut self.out,
116                builder: SubscriptionSchedulePhaseConfigurationBuilder::deser_default(),
117            }))
118        }
119    }
120
121    impl MapBuilder for SubscriptionSchedulePhaseConfigurationBuilder {
122        type Out = SubscriptionSchedulePhaseConfiguration;
123        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
124            Ok(match k {
125                "add_invoice_items" => Deserialize::begin(&mut self.add_invoice_items),
126                "application_fee_percent" => Deserialize::begin(&mut self.application_fee_percent),
127                "automatic_tax" => Deserialize::begin(&mut self.automatic_tax),
128                "billing_cycle_anchor" => Deserialize::begin(&mut self.billing_cycle_anchor),
129                "billing_thresholds" => Deserialize::begin(&mut self.billing_thresholds),
130                "collection_method" => Deserialize::begin(&mut self.collection_method),
131                "currency" => Deserialize::begin(&mut self.currency),
132                "default_payment_method" => Deserialize::begin(&mut self.default_payment_method),
133                "default_tax_rates" => Deserialize::begin(&mut self.default_tax_rates),
134                "description" => Deserialize::begin(&mut self.description),
135                "discounts" => Deserialize::begin(&mut self.discounts),
136                "end_date" => Deserialize::begin(&mut self.end_date),
137                "invoice_settings" => Deserialize::begin(&mut self.invoice_settings),
138                "items" => Deserialize::begin(&mut self.items),
139                "metadata" => Deserialize::begin(&mut self.metadata),
140                "on_behalf_of" => Deserialize::begin(&mut self.on_behalf_of),
141                "proration_behavior" => Deserialize::begin(&mut self.proration_behavior),
142                "start_date" => Deserialize::begin(&mut self.start_date),
143                "transfer_data" => Deserialize::begin(&mut self.transfer_data),
144                "trial_end" => Deserialize::begin(&mut self.trial_end),
145                _ => <dyn Visitor>::ignore(),
146            })
147        }
148
149        fn deser_default() -> Self {
150            Self {
151                add_invoice_items: Deserialize::default(),
152                application_fee_percent: Deserialize::default(),
153                automatic_tax: Deserialize::default(),
154                billing_cycle_anchor: Deserialize::default(),
155                billing_thresholds: Deserialize::default(),
156                collection_method: Deserialize::default(),
157                currency: Deserialize::default(),
158                default_payment_method: Deserialize::default(),
159                default_tax_rates: Deserialize::default(),
160                description: Deserialize::default(),
161                discounts: Deserialize::default(),
162                end_date: Deserialize::default(),
163                invoice_settings: Deserialize::default(),
164                items: Deserialize::default(),
165                metadata: Deserialize::default(),
166                on_behalf_of: Deserialize::default(),
167                proration_behavior: Deserialize::default(),
168                start_date: Deserialize::default(),
169                transfer_data: Deserialize::default(),
170                trial_end: Deserialize::default(),
171            }
172        }
173
174        fn take_out(&mut self) -> Option<Self::Out> {
175            let (
176                Some(add_invoice_items),
177                Some(application_fee_percent),
178                Some(automatic_tax),
179                Some(billing_cycle_anchor),
180                Some(billing_thresholds),
181                Some(collection_method),
182                Some(currency),
183                Some(default_payment_method),
184                Some(default_tax_rates),
185                Some(description),
186                Some(discounts),
187                Some(end_date),
188                Some(invoice_settings),
189                Some(items),
190                Some(metadata),
191                Some(on_behalf_of),
192                Some(proration_behavior),
193                Some(start_date),
194                Some(transfer_data),
195                Some(trial_end),
196            ) = (
197                self.add_invoice_items.take(),
198                self.application_fee_percent,
199                self.automatic_tax.take(),
200                self.billing_cycle_anchor.take(),
201                self.billing_thresholds,
202                self.collection_method.take(),
203                self.currency.take(),
204                self.default_payment_method.take(),
205                self.default_tax_rates.take(),
206                self.description.take(),
207                self.discounts.take(),
208                self.end_date,
209                self.invoice_settings.take(),
210                self.items.take(),
211                self.metadata.take(),
212                self.on_behalf_of.take(),
213                self.proration_behavior.take(),
214                self.start_date,
215                self.transfer_data.take(),
216                self.trial_end,
217            )
218            else {
219                return None;
220            };
221            Some(Self::Out {
222                add_invoice_items,
223                application_fee_percent,
224                automatic_tax,
225                billing_cycle_anchor,
226                billing_thresholds,
227                collection_method,
228                currency,
229                default_payment_method,
230                default_tax_rates,
231                description,
232                discounts,
233                end_date,
234                invoice_settings,
235                items,
236                metadata,
237                on_behalf_of,
238                proration_behavior,
239                start_date,
240                transfer_data,
241                trial_end,
242            })
243        }
244    }
245
246    impl Map for Builder<'_> {
247        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
248            self.builder.key(k)
249        }
250
251        fn finish(&mut self) -> Result<()> {
252            *self.out = self.builder.take_out();
253            Ok(())
254        }
255    }
256
257    impl ObjectDeser for SubscriptionSchedulePhaseConfiguration {
258        type Builder = SubscriptionSchedulePhaseConfigurationBuilder;
259    }
260
261    impl FromValueOpt for SubscriptionSchedulePhaseConfiguration {
262        fn from_value(v: Value) -> Option<Self> {
263            let Value::Object(obj) = v else {
264                return None;
265            };
266            let mut b = SubscriptionSchedulePhaseConfigurationBuilder::deser_default();
267            for (k, v) in obj {
268                match k.as_str() {
269                    "add_invoice_items" => b.add_invoice_items = FromValueOpt::from_value(v),
270                    "application_fee_percent" => {
271                        b.application_fee_percent = FromValueOpt::from_value(v)
272                    }
273                    "automatic_tax" => b.automatic_tax = FromValueOpt::from_value(v),
274                    "billing_cycle_anchor" => b.billing_cycle_anchor = FromValueOpt::from_value(v),
275                    "billing_thresholds" => b.billing_thresholds = FromValueOpt::from_value(v),
276                    "collection_method" => b.collection_method = FromValueOpt::from_value(v),
277                    "currency" => b.currency = FromValueOpt::from_value(v),
278                    "default_payment_method" => {
279                        b.default_payment_method = FromValueOpt::from_value(v)
280                    }
281                    "default_tax_rates" => b.default_tax_rates = FromValueOpt::from_value(v),
282                    "description" => b.description = FromValueOpt::from_value(v),
283                    "discounts" => b.discounts = FromValueOpt::from_value(v),
284                    "end_date" => b.end_date = FromValueOpt::from_value(v),
285                    "invoice_settings" => b.invoice_settings = FromValueOpt::from_value(v),
286                    "items" => b.items = FromValueOpt::from_value(v),
287                    "metadata" => b.metadata = FromValueOpt::from_value(v),
288                    "on_behalf_of" => b.on_behalf_of = FromValueOpt::from_value(v),
289                    "proration_behavior" => b.proration_behavior = FromValueOpt::from_value(v),
290                    "start_date" => b.start_date = FromValueOpt::from_value(v),
291                    "transfer_data" => b.transfer_data = FromValueOpt::from_value(v),
292                    "trial_end" => b.trial_end = FromValueOpt::from_value(v),
293                    _ => {}
294                }
295            }
296            b.take_out()
297        }
298    }
299};
300/// Possible values are `phase_start` or `automatic`.
301/// If `phase_start` then billing cycle anchor of the subscription is set to the start of the phase when entering the phase.
302/// If `automatic` then the billing cycle anchor is automatically modified as needed when entering the phase.
303/// For more information, see the billing cycle [documentation](https://stripe.com/docs/billing/subscriptions/billing-cycle).
304#[derive(Clone, Eq, PartialEq)]
305#[non_exhaustive]
306pub enum SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
307    Automatic,
308    PhaseStart,
309    /// An unrecognized value from Stripe. Should not be used as a request parameter.
310    Unknown(String),
311}
312impl SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
313    pub fn as_str(&self) -> &str {
314        use SubscriptionSchedulePhaseConfigurationBillingCycleAnchor::*;
315        match self {
316            Automatic => "automatic",
317            PhaseStart => "phase_start",
318            Unknown(v) => v,
319        }
320    }
321}
322
323impl std::str::FromStr for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
324    type Err = std::convert::Infallible;
325    fn from_str(s: &str) -> Result<Self, Self::Err> {
326        use SubscriptionSchedulePhaseConfigurationBillingCycleAnchor::*;
327        match s {
328            "automatic" => Ok(Automatic),
329            "phase_start" => Ok(PhaseStart),
330            v => {
331                tracing::warn!(
332                    "Unknown value '{}' for enum '{}'",
333                    v,
334                    "SubscriptionSchedulePhaseConfigurationBillingCycleAnchor"
335                );
336                Ok(Unknown(v.to_owned()))
337            }
338        }
339    }
340}
341impl std::fmt::Display for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
342    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
343        f.write_str(self.as_str())
344    }
345}
346
347impl std::fmt::Debug for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
348    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
349        f.write_str(self.as_str())
350    }
351}
352#[cfg(feature = "serialize")]
353impl serde::Serialize for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
354    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
355    where
356        S: serde::Serializer,
357    {
358        serializer.serialize_str(self.as_str())
359    }
360}
361impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
362    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
363        crate::Place::new(out)
364    }
365}
366
367impl miniserde::de::Visitor
368    for crate::Place<SubscriptionSchedulePhaseConfigurationBillingCycleAnchor>
369{
370    fn string(&mut self, s: &str) -> miniserde::Result<()> {
371        use std::str::FromStr;
372        self.out = Some(
373            SubscriptionSchedulePhaseConfigurationBillingCycleAnchor::from_str(s)
374                .expect("infallible"),
375        );
376        Ok(())
377    }
378}
379
380stripe_types::impl_from_val_with_from_str!(
381    SubscriptionSchedulePhaseConfigurationBillingCycleAnchor
382);
383#[cfg(feature = "deserialize")]
384impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationBillingCycleAnchor {
385    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
386        use std::str::FromStr;
387        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
388        Ok(Self::from_str(&s).expect("infallible"))
389    }
390}
391/// Either `charge_automatically`, or `send_invoice`.
392/// When charging automatically, Stripe will attempt to pay the underlying subscription at the end of each billing cycle using the default source attached to the customer.
393/// When sending an invoice, Stripe will email your customer an invoice with payment instructions and mark the subscription as `active`.
394#[derive(Clone, Eq, PartialEq)]
395#[non_exhaustive]
396pub enum SubscriptionSchedulePhaseConfigurationCollectionMethod {
397    ChargeAutomatically,
398    SendInvoice,
399    /// An unrecognized value from Stripe. Should not be used as a request parameter.
400    Unknown(String),
401}
402impl SubscriptionSchedulePhaseConfigurationCollectionMethod {
403    pub fn as_str(&self) -> &str {
404        use SubscriptionSchedulePhaseConfigurationCollectionMethod::*;
405        match self {
406            ChargeAutomatically => "charge_automatically",
407            SendInvoice => "send_invoice",
408            Unknown(v) => v,
409        }
410    }
411}
412
413impl std::str::FromStr for SubscriptionSchedulePhaseConfigurationCollectionMethod {
414    type Err = std::convert::Infallible;
415    fn from_str(s: &str) -> Result<Self, Self::Err> {
416        use SubscriptionSchedulePhaseConfigurationCollectionMethod::*;
417        match s {
418            "charge_automatically" => Ok(ChargeAutomatically),
419            "send_invoice" => Ok(SendInvoice),
420            v => {
421                tracing::warn!(
422                    "Unknown value '{}' for enum '{}'",
423                    v,
424                    "SubscriptionSchedulePhaseConfigurationCollectionMethod"
425                );
426                Ok(Unknown(v.to_owned()))
427            }
428        }
429    }
430}
431impl std::fmt::Display for SubscriptionSchedulePhaseConfigurationCollectionMethod {
432    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
433        f.write_str(self.as_str())
434    }
435}
436
437impl std::fmt::Debug for SubscriptionSchedulePhaseConfigurationCollectionMethod {
438    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
439        f.write_str(self.as_str())
440    }
441}
442#[cfg(feature = "serialize")]
443impl serde::Serialize for SubscriptionSchedulePhaseConfigurationCollectionMethod {
444    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
445    where
446        S: serde::Serializer,
447    {
448        serializer.serialize_str(self.as_str())
449    }
450}
451impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationCollectionMethod {
452    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
453        crate::Place::new(out)
454    }
455}
456
457impl miniserde::de::Visitor
458    for crate::Place<SubscriptionSchedulePhaseConfigurationCollectionMethod>
459{
460    fn string(&mut self, s: &str) -> miniserde::Result<()> {
461        use std::str::FromStr;
462        self.out = Some(
463            SubscriptionSchedulePhaseConfigurationCollectionMethod::from_str(s)
464                .expect("infallible"),
465        );
466        Ok(())
467    }
468}
469
470stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationCollectionMethod);
471#[cfg(feature = "deserialize")]
472impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationCollectionMethod {
473    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
474        use std::str::FromStr;
475        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
476        Ok(Self::from_str(&s).expect("infallible"))
477    }
478}
479/// When transitioning phases, controls how prorations are handled (if any).
480/// Possible values are `create_prorations`, `none`, and `always_invoice`.
481#[derive(Clone, Eq, PartialEq)]
482#[non_exhaustive]
483pub enum SubscriptionSchedulePhaseConfigurationProrationBehavior {
484    AlwaysInvoice,
485    CreateProrations,
486    None,
487    /// An unrecognized value from Stripe. Should not be used as a request parameter.
488    Unknown(String),
489}
490impl SubscriptionSchedulePhaseConfigurationProrationBehavior {
491    pub fn as_str(&self) -> &str {
492        use SubscriptionSchedulePhaseConfigurationProrationBehavior::*;
493        match self {
494            AlwaysInvoice => "always_invoice",
495            CreateProrations => "create_prorations",
496            None => "none",
497            Unknown(v) => v,
498        }
499    }
500}
501
502impl std::str::FromStr for SubscriptionSchedulePhaseConfigurationProrationBehavior {
503    type Err = std::convert::Infallible;
504    fn from_str(s: &str) -> Result<Self, Self::Err> {
505        use SubscriptionSchedulePhaseConfigurationProrationBehavior::*;
506        match s {
507            "always_invoice" => Ok(AlwaysInvoice),
508            "create_prorations" => Ok(CreateProrations),
509            "none" => Ok(None),
510            v => {
511                tracing::warn!(
512                    "Unknown value '{}' for enum '{}'",
513                    v,
514                    "SubscriptionSchedulePhaseConfigurationProrationBehavior"
515                );
516                Ok(Unknown(v.to_owned()))
517            }
518        }
519    }
520}
521impl std::fmt::Display for SubscriptionSchedulePhaseConfigurationProrationBehavior {
522    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
523        f.write_str(self.as_str())
524    }
525}
526
527impl std::fmt::Debug for SubscriptionSchedulePhaseConfigurationProrationBehavior {
528    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
529        f.write_str(self.as_str())
530    }
531}
532#[cfg(feature = "serialize")]
533impl serde::Serialize for SubscriptionSchedulePhaseConfigurationProrationBehavior {
534    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
535    where
536        S: serde::Serializer,
537    {
538        serializer.serialize_str(self.as_str())
539    }
540}
541impl miniserde::Deserialize for SubscriptionSchedulePhaseConfigurationProrationBehavior {
542    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
543        crate::Place::new(out)
544    }
545}
546
547impl miniserde::de::Visitor
548    for crate::Place<SubscriptionSchedulePhaseConfigurationProrationBehavior>
549{
550    fn string(&mut self, s: &str) -> miniserde::Result<()> {
551        use std::str::FromStr;
552        self.out = Some(
553            SubscriptionSchedulePhaseConfigurationProrationBehavior::from_str(s)
554                .expect("infallible"),
555        );
556        Ok(())
557    }
558}
559
560stripe_types::impl_from_val_with_from_str!(SubscriptionSchedulePhaseConfigurationProrationBehavior);
561#[cfg(feature = "deserialize")]
562impl<'de> serde::Deserialize<'de> for SubscriptionSchedulePhaseConfigurationProrationBehavior {
563    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
564        use std::str::FromStr;
565        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
566        Ok(Self::from_str(&s).expect("infallible"))
567    }
568}