stripe_core/customer/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5/// Permanently deletes a customer.
6/// It cannot be undone.
7/// Also immediately cancels any active subscriptions on the customer.
8#[derive(Clone, Debug, serde::Serialize)]
9pub struct DeleteCustomer {
10    customer: stripe_shared::CustomerId,
11}
12impl DeleteCustomer {
13    /// Construct a new `DeleteCustomer`.
14    pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
15        Self { customer: customer.into() }
16    }
17}
18impl DeleteCustomer {
19    /// Send the request and return the deserialized response.
20    pub async fn send<C: StripeClient>(
21        &self,
22        client: &C,
23    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
24        self.customize().send(client).await
25    }
26
27    /// Send the request and return the deserialized response, blocking until completion.
28    pub fn send_blocking<C: StripeBlockingClient>(
29        &self,
30        client: &C,
31    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
32        self.customize().send_blocking(client)
33    }
34}
35
36impl StripeRequest for DeleteCustomer {
37    type Output = stripe_shared::DeletedCustomer;
38
39    fn build(&self) -> RequestBuilder {
40        let customer = &self.customer;
41        RequestBuilder::new(StripeMethod::Delete, format!("/customers/{customer}"))
42    }
43}
44/// Removes the currently applied discount on a customer.
45#[derive(Clone, Debug, serde::Serialize)]
46pub struct DeleteDiscountCustomer {
47    customer: stripe_shared::CustomerId,
48}
49impl DeleteDiscountCustomer {
50    /// Construct a new `DeleteDiscountCustomer`.
51    pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
52        Self { customer: customer.into() }
53    }
54}
55impl DeleteDiscountCustomer {
56    /// Send the request and return the deserialized response.
57    pub async fn send<C: StripeClient>(
58        &self,
59        client: &C,
60    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
61        self.customize().send(client).await
62    }
63
64    /// Send the request and return the deserialized response, blocking until completion.
65    pub fn send_blocking<C: StripeBlockingClient>(
66        &self,
67        client: &C,
68    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
69        self.customize().send_blocking(client)
70    }
71}
72
73impl StripeRequest for DeleteDiscountCustomer {
74    type Output = stripe_shared::DeletedDiscount;
75
76    fn build(&self) -> RequestBuilder {
77        let customer = &self.customer;
78        RequestBuilder::new(StripeMethod::Delete, format!("/customers/{customer}/discount"))
79    }
80}
81#[derive(Clone, Debug, serde::Serialize)]
82struct ListCustomerBuilder {
83    #[serde(skip_serializing_if = "Option::is_none")]
84    created: Option<stripe_types::RangeQueryTs>,
85    #[serde(skip_serializing_if = "Option::is_none")]
86    email: Option<String>,
87    #[serde(skip_serializing_if = "Option::is_none")]
88    ending_before: Option<String>,
89    #[serde(skip_serializing_if = "Option::is_none")]
90    expand: Option<Vec<String>>,
91    #[serde(skip_serializing_if = "Option::is_none")]
92    limit: Option<i64>,
93    #[serde(skip_serializing_if = "Option::is_none")]
94    starting_after: Option<String>,
95    #[serde(skip_serializing_if = "Option::is_none")]
96    test_clock: Option<String>,
97}
98impl ListCustomerBuilder {
99    fn new() -> Self {
100        Self {
101            created: None,
102            email: None,
103            ending_before: None,
104            expand: None,
105            limit: None,
106            starting_after: None,
107            test_clock: None,
108        }
109    }
110}
111/// Returns a list of your customers.
112/// The customers are returned sorted by creation date, with the most recent customers appearing first.
113#[derive(Clone, Debug, serde::Serialize)]
114pub struct ListCustomer {
115    inner: ListCustomerBuilder,
116}
117impl ListCustomer {
118    /// Construct a new `ListCustomer`.
119    pub fn new() -> Self {
120        Self { inner: ListCustomerBuilder::new() }
121    }
122    /// Only return customers that were created during the given date interval.
123    pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
124        self.inner.created = Some(created.into());
125        self
126    }
127    /// A case-sensitive filter on the list based on the customer's `email` field.
128    /// The value must be a string.
129    pub fn email(mut self, email: impl Into<String>) -> Self {
130        self.inner.email = Some(email.into());
131        self
132    }
133    /// A cursor for use in pagination.
134    /// `ending_before` is an object ID that defines your place in the list.
135    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
136    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
137        self.inner.ending_before = Some(ending_before.into());
138        self
139    }
140    /// Specifies which fields in the response should be expanded.
141    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
142        self.inner.expand = Some(expand.into());
143        self
144    }
145    /// A limit on the number of objects to be returned.
146    /// Limit can range between 1 and 100, and the default is 10.
147    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
148        self.inner.limit = Some(limit.into());
149        self
150    }
151    /// A cursor for use in pagination.
152    /// `starting_after` is an object ID that defines your place in the list.
153    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
154    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
155        self.inner.starting_after = Some(starting_after.into());
156        self
157    }
158    /// Provides a list of customers that are associated with the specified test clock.
159    /// The response will not include customers with test clocks if this parameter is not set.
160    pub fn test_clock(mut self, test_clock: impl Into<String>) -> Self {
161        self.inner.test_clock = Some(test_clock.into());
162        self
163    }
164}
165impl Default for ListCustomer {
166    fn default() -> Self {
167        Self::new()
168    }
169}
170impl ListCustomer {
171    /// Send the request and return the deserialized response.
172    pub async fn send<C: StripeClient>(
173        &self,
174        client: &C,
175    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
176        self.customize().send(client).await
177    }
178
179    /// Send the request and return the deserialized response, blocking until completion.
180    pub fn send_blocking<C: StripeBlockingClient>(
181        &self,
182        client: &C,
183    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
184        self.customize().send_blocking(client)
185    }
186
187    pub fn paginate(
188        &self,
189    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::Customer>> {
190        stripe_client_core::ListPaginator::new_list("/customers", &self.inner)
191    }
192}
193
194impl StripeRequest for ListCustomer {
195    type Output = stripe_types::List<stripe_shared::Customer>;
196
197    fn build(&self) -> RequestBuilder {
198        RequestBuilder::new(StripeMethod::Get, "/customers").query(&self.inner)
199    }
200}
201#[derive(Clone, Debug, serde::Serialize)]
202struct RetrieveCustomerBuilder {
203    #[serde(skip_serializing_if = "Option::is_none")]
204    expand: Option<Vec<String>>,
205}
206impl RetrieveCustomerBuilder {
207    fn new() -> Self {
208        Self { expand: None }
209    }
210}
211/// Retrieves a Customer object.
212#[derive(Clone, Debug, serde::Serialize)]
213pub struct RetrieveCustomer {
214    inner: RetrieveCustomerBuilder,
215    customer: stripe_shared::CustomerId,
216}
217impl RetrieveCustomer {
218    /// Construct a new `RetrieveCustomer`.
219    pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
220        Self { customer: customer.into(), inner: RetrieveCustomerBuilder::new() }
221    }
222    /// Specifies which fields in the response should be expanded.
223    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
224        self.inner.expand = Some(expand.into());
225        self
226    }
227}
228impl RetrieveCustomer {
229    /// Send the request and return the deserialized response.
230    pub async fn send<C: StripeClient>(
231        &self,
232        client: &C,
233    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
234        self.customize().send(client).await
235    }
236
237    /// Send the request and return the deserialized response, blocking until completion.
238    pub fn send_blocking<C: StripeBlockingClient>(
239        &self,
240        client: &C,
241    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
242        self.customize().send_blocking(client)
243    }
244}
245
246impl StripeRequest for RetrieveCustomer {
247    type Output = RetrieveCustomerReturned;
248
249    fn build(&self) -> RequestBuilder {
250        let customer = &self.customer;
251        RequestBuilder::new(StripeMethod::Get, format!("/customers/{customer}")).query(&self.inner)
252    }
253}
254#[derive(Clone, Debug)]
255#[cfg_attr(feature = "serialize", derive(serde::Serialize))]
256#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
257#[cfg_attr(any(feature = "deserialize", feature = "serialize"), serde(untagged))]
258pub enum RetrieveCustomerReturned {
259    Customer(stripe_shared::Customer),
260    DeletedCustomer(stripe_shared::DeletedCustomer),
261}
262
263#[derive(Default)]
264pub struct RetrieveCustomerReturnedBuilder {
265    inner: stripe_types::miniserde_helpers::MaybeDeletedBuilderInner,
266}
267
268const _: () = {
269    use miniserde::de::{Map, Visitor};
270    use miniserde::json::Value;
271    use miniserde::{Deserialize, Result, make_place};
272    use stripe_types::MapBuilder;
273    use stripe_types::miniserde_helpers::FromValueOpt;
274
275    use super::*;
276
277    make_place!(Place);
278
279    struct Builder<'a> {
280        out: &'a mut Option<RetrieveCustomerReturned>,
281        builder: RetrieveCustomerReturnedBuilder,
282    }
283
284    impl Deserialize for RetrieveCustomerReturned {
285        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
286            Place::new(out)
287        }
288    }
289
290    impl Visitor for Place<RetrieveCustomerReturned> {
291        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
292            Ok(Box::new(Builder { out: &mut self.out, builder: Default::default() }))
293        }
294    }
295
296    impl Map for Builder<'_> {
297        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
298            self.builder.key(k)
299        }
300
301        fn finish(&mut self) -> Result<()> {
302            *self.out = self.builder.take_out();
303            Ok(())
304        }
305    }
306
307    impl MapBuilder for RetrieveCustomerReturnedBuilder {
308        type Out = RetrieveCustomerReturned;
309        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
310            self.inner.key_inner(k)
311        }
312
313        fn deser_default() -> Self {
314            Self::default()
315        }
316
317        fn take_out(&mut self) -> Option<Self::Out> {
318            let (deleted, o) = self.inner.finish_inner()?;
319            Some(if deleted {
320                RetrieveCustomerReturned::DeletedCustomer(FromValueOpt::from_value(Value::Object(
321                    o,
322                ))?)
323            } else {
324                RetrieveCustomerReturned::Customer(FromValueOpt::from_value(Value::Object(o))?)
325            })
326        }
327    }
328
329    impl stripe_types::ObjectDeser for RetrieveCustomerReturned {
330        type Builder = RetrieveCustomerReturnedBuilder;
331    }
332};
333
334#[derive(Clone, Debug, serde::Serialize)]
335struct BalanceTransactionsCustomerBuilder {
336    #[serde(skip_serializing_if = "Option::is_none")]
337    created: Option<stripe_types::RangeQueryTs>,
338    #[serde(skip_serializing_if = "Option::is_none")]
339    ending_before: Option<String>,
340    #[serde(skip_serializing_if = "Option::is_none")]
341    expand: Option<Vec<String>>,
342    #[serde(skip_serializing_if = "Option::is_none")]
343    limit: Option<i64>,
344    #[serde(skip_serializing_if = "Option::is_none")]
345    starting_after: Option<String>,
346}
347impl BalanceTransactionsCustomerBuilder {
348    fn new() -> Self {
349        Self { created: None, ending_before: None, expand: None, limit: None, starting_after: None }
350    }
351}
352/// Returns a list of transactions that updated the customer’s [balances](https://stripe.com/docs/billing/customer/balance).
353#[derive(Clone, Debug, serde::Serialize)]
354pub struct BalanceTransactionsCustomer {
355    inner: BalanceTransactionsCustomerBuilder,
356    customer: stripe_shared::CustomerId,
357}
358impl BalanceTransactionsCustomer {
359    /// Construct a new `BalanceTransactionsCustomer`.
360    pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
361        Self { customer: customer.into(), inner: BalanceTransactionsCustomerBuilder::new() }
362    }
363    /// Only return customer balance transactions that were created during the given date interval.
364    pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
365        self.inner.created = Some(created.into());
366        self
367    }
368    /// A cursor for use in pagination.
369    /// `ending_before` is an object ID that defines your place in the list.
370    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
371    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
372        self.inner.ending_before = Some(ending_before.into());
373        self
374    }
375    /// Specifies which fields in the response should be expanded.
376    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
377        self.inner.expand = Some(expand.into());
378        self
379    }
380    /// A limit on the number of objects to be returned.
381    /// Limit can range between 1 and 100, and the default is 10.
382    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
383        self.inner.limit = Some(limit.into());
384        self
385    }
386    /// A cursor for use in pagination.
387    /// `starting_after` is an object ID that defines your place in the list.
388    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
389    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
390        self.inner.starting_after = Some(starting_after.into());
391        self
392    }
393}
394impl BalanceTransactionsCustomer {
395    /// Send the request and return the deserialized response.
396    pub async fn send<C: StripeClient>(
397        &self,
398        client: &C,
399    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
400        self.customize().send(client).await
401    }
402
403    /// Send the request and return the deserialized response, blocking until completion.
404    pub fn send_blocking<C: StripeBlockingClient>(
405        &self,
406        client: &C,
407    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
408        self.customize().send_blocking(client)
409    }
410
411    pub fn paginate(
412        &self,
413    ) -> stripe_client_core::ListPaginator<
414        stripe_types::List<stripe_shared::CustomerBalanceTransaction>,
415    > {
416        let customer = &self.customer;
417
418        stripe_client_core::ListPaginator::new_list(
419            format!("/customers/{customer}/balance_transactions"),
420            &self.inner,
421        )
422    }
423}
424
425impl StripeRequest for BalanceTransactionsCustomer {
426    type Output = stripe_types::List<stripe_shared::CustomerBalanceTransaction>;
427
428    fn build(&self) -> RequestBuilder {
429        let customer = &self.customer;
430        RequestBuilder::new(
431            StripeMethod::Get,
432            format!("/customers/{customer}/balance_transactions"),
433        )
434        .query(&self.inner)
435    }
436}
437#[derive(Clone, Debug, serde::Serialize)]
438struct ListPaymentMethodsCustomerBuilder {
439    #[serde(skip_serializing_if = "Option::is_none")]
440    allow_redisplay: Option<ListPaymentMethodsCustomerAllowRedisplay>,
441    #[serde(skip_serializing_if = "Option::is_none")]
442    ending_before: Option<String>,
443    #[serde(skip_serializing_if = "Option::is_none")]
444    expand: Option<Vec<String>>,
445    #[serde(skip_serializing_if = "Option::is_none")]
446    limit: Option<i64>,
447    #[serde(skip_serializing_if = "Option::is_none")]
448    starting_after: Option<String>,
449    #[serde(rename = "type")]
450    #[serde(skip_serializing_if = "Option::is_none")]
451    type_: Option<ListPaymentMethodsCustomerType>,
452}
453impl ListPaymentMethodsCustomerBuilder {
454    fn new() -> Self {
455        Self {
456            allow_redisplay: None,
457            ending_before: None,
458            expand: None,
459            limit: None,
460            starting_after: None,
461            type_: None,
462        }
463    }
464}
465/// This field indicates whether this payment method can be shown again to its customer in a checkout flow.
466/// Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
467#[derive(Clone, Eq, PartialEq)]
468#[non_exhaustive]
469pub enum ListPaymentMethodsCustomerAllowRedisplay {
470    Always,
471    Limited,
472    Unspecified,
473    /// An unrecognized value from Stripe. Should not be used as a request parameter.
474    Unknown(String),
475}
476impl ListPaymentMethodsCustomerAllowRedisplay {
477    pub fn as_str(&self) -> &str {
478        use ListPaymentMethodsCustomerAllowRedisplay::*;
479        match self {
480            Always => "always",
481            Limited => "limited",
482            Unspecified => "unspecified",
483            Unknown(v) => v,
484        }
485    }
486}
487
488impl std::str::FromStr for ListPaymentMethodsCustomerAllowRedisplay {
489    type Err = std::convert::Infallible;
490    fn from_str(s: &str) -> Result<Self, Self::Err> {
491        use ListPaymentMethodsCustomerAllowRedisplay::*;
492        match s {
493            "always" => Ok(Always),
494            "limited" => Ok(Limited),
495            "unspecified" => Ok(Unspecified),
496            v => {
497                tracing::warn!(
498                    "Unknown value '{}' for enum '{}'",
499                    v,
500                    "ListPaymentMethodsCustomerAllowRedisplay"
501                );
502                Ok(Unknown(v.to_owned()))
503            }
504        }
505    }
506}
507impl std::fmt::Display for ListPaymentMethodsCustomerAllowRedisplay {
508    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
509        f.write_str(self.as_str())
510    }
511}
512
513impl std::fmt::Debug for ListPaymentMethodsCustomerAllowRedisplay {
514    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
515        f.write_str(self.as_str())
516    }
517}
518impl serde::Serialize for ListPaymentMethodsCustomerAllowRedisplay {
519    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
520    where
521        S: serde::Serializer,
522    {
523        serializer.serialize_str(self.as_str())
524    }
525}
526#[cfg(feature = "deserialize")]
527impl<'de> serde::Deserialize<'de> for ListPaymentMethodsCustomerAllowRedisplay {
528    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
529        use std::str::FromStr;
530        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
531        Ok(Self::from_str(&s).expect("infallible"))
532    }
533}
534/// An optional filter on the list, based on the object `type` field.
535/// Without the filter, the list includes all current and future payment method types.
536/// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request.
537#[derive(Clone, Eq, PartialEq)]
538#[non_exhaustive]
539pub enum ListPaymentMethodsCustomerType {
540    AcssDebit,
541    Affirm,
542    AfterpayClearpay,
543    Alipay,
544    Alma,
545    AmazonPay,
546    AuBecsDebit,
547    BacsDebit,
548    Bancontact,
549    Billie,
550    Blik,
551    Boleto,
552    Card,
553    Cashapp,
554    Crypto,
555    Custom,
556    CustomerBalance,
557    Eps,
558    Fpx,
559    Giropay,
560    Grabpay,
561    Ideal,
562    KakaoPay,
563    Klarna,
564    Konbini,
565    KrCard,
566    Link,
567    MbWay,
568    Mobilepay,
569    Multibanco,
570    NaverPay,
571    NzBankAccount,
572    Oxxo,
573    P24,
574    PayByBank,
575    Payco,
576    Paynow,
577    Paypal,
578    Pix,
579    Promptpay,
580    RevolutPay,
581    SamsungPay,
582    Satispay,
583    SepaDebit,
584    Sofort,
585    Swish,
586    Twint,
587    UsBankAccount,
588    WechatPay,
589    Zip,
590    /// An unrecognized value from Stripe. Should not be used as a request parameter.
591    Unknown(String),
592}
593impl ListPaymentMethodsCustomerType {
594    pub fn as_str(&self) -> &str {
595        use ListPaymentMethodsCustomerType::*;
596        match self {
597            AcssDebit => "acss_debit",
598            Affirm => "affirm",
599            AfterpayClearpay => "afterpay_clearpay",
600            Alipay => "alipay",
601            Alma => "alma",
602            AmazonPay => "amazon_pay",
603            AuBecsDebit => "au_becs_debit",
604            BacsDebit => "bacs_debit",
605            Bancontact => "bancontact",
606            Billie => "billie",
607            Blik => "blik",
608            Boleto => "boleto",
609            Card => "card",
610            Cashapp => "cashapp",
611            Crypto => "crypto",
612            Custom => "custom",
613            CustomerBalance => "customer_balance",
614            Eps => "eps",
615            Fpx => "fpx",
616            Giropay => "giropay",
617            Grabpay => "grabpay",
618            Ideal => "ideal",
619            KakaoPay => "kakao_pay",
620            Klarna => "klarna",
621            Konbini => "konbini",
622            KrCard => "kr_card",
623            Link => "link",
624            MbWay => "mb_way",
625            Mobilepay => "mobilepay",
626            Multibanco => "multibanco",
627            NaverPay => "naver_pay",
628            NzBankAccount => "nz_bank_account",
629            Oxxo => "oxxo",
630            P24 => "p24",
631            PayByBank => "pay_by_bank",
632            Payco => "payco",
633            Paynow => "paynow",
634            Paypal => "paypal",
635            Pix => "pix",
636            Promptpay => "promptpay",
637            RevolutPay => "revolut_pay",
638            SamsungPay => "samsung_pay",
639            Satispay => "satispay",
640            SepaDebit => "sepa_debit",
641            Sofort => "sofort",
642            Swish => "swish",
643            Twint => "twint",
644            UsBankAccount => "us_bank_account",
645            WechatPay => "wechat_pay",
646            Zip => "zip",
647            Unknown(v) => v,
648        }
649    }
650}
651
652impl std::str::FromStr for ListPaymentMethodsCustomerType {
653    type Err = std::convert::Infallible;
654    fn from_str(s: &str) -> Result<Self, Self::Err> {
655        use ListPaymentMethodsCustomerType::*;
656        match s {
657            "acss_debit" => Ok(AcssDebit),
658            "affirm" => Ok(Affirm),
659            "afterpay_clearpay" => Ok(AfterpayClearpay),
660            "alipay" => Ok(Alipay),
661            "alma" => Ok(Alma),
662            "amazon_pay" => Ok(AmazonPay),
663            "au_becs_debit" => Ok(AuBecsDebit),
664            "bacs_debit" => Ok(BacsDebit),
665            "bancontact" => Ok(Bancontact),
666            "billie" => Ok(Billie),
667            "blik" => Ok(Blik),
668            "boleto" => Ok(Boleto),
669            "card" => Ok(Card),
670            "cashapp" => Ok(Cashapp),
671            "crypto" => Ok(Crypto),
672            "custom" => Ok(Custom),
673            "customer_balance" => Ok(CustomerBalance),
674            "eps" => Ok(Eps),
675            "fpx" => Ok(Fpx),
676            "giropay" => Ok(Giropay),
677            "grabpay" => Ok(Grabpay),
678            "ideal" => Ok(Ideal),
679            "kakao_pay" => Ok(KakaoPay),
680            "klarna" => Ok(Klarna),
681            "konbini" => Ok(Konbini),
682            "kr_card" => Ok(KrCard),
683            "link" => Ok(Link),
684            "mb_way" => Ok(MbWay),
685            "mobilepay" => Ok(Mobilepay),
686            "multibanco" => Ok(Multibanco),
687            "naver_pay" => Ok(NaverPay),
688            "nz_bank_account" => Ok(NzBankAccount),
689            "oxxo" => Ok(Oxxo),
690            "p24" => Ok(P24),
691            "pay_by_bank" => Ok(PayByBank),
692            "payco" => Ok(Payco),
693            "paynow" => Ok(Paynow),
694            "paypal" => Ok(Paypal),
695            "pix" => Ok(Pix),
696            "promptpay" => Ok(Promptpay),
697            "revolut_pay" => Ok(RevolutPay),
698            "samsung_pay" => Ok(SamsungPay),
699            "satispay" => Ok(Satispay),
700            "sepa_debit" => Ok(SepaDebit),
701            "sofort" => Ok(Sofort),
702            "swish" => Ok(Swish),
703            "twint" => Ok(Twint),
704            "us_bank_account" => Ok(UsBankAccount),
705            "wechat_pay" => Ok(WechatPay),
706            "zip" => Ok(Zip),
707            v => {
708                tracing::warn!(
709                    "Unknown value '{}' for enum '{}'",
710                    v,
711                    "ListPaymentMethodsCustomerType"
712                );
713                Ok(Unknown(v.to_owned()))
714            }
715        }
716    }
717}
718impl std::fmt::Display for ListPaymentMethodsCustomerType {
719    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
720        f.write_str(self.as_str())
721    }
722}
723
724impl std::fmt::Debug for ListPaymentMethodsCustomerType {
725    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
726        f.write_str(self.as_str())
727    }
728}
729impl serde::Serialize for ListPaymentMethodsCustomerType {
730    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
731    where
732        S: serde::Serializer,
733    {
734        serializer.serialize_str(self.as_str())
735    }
736}
737#[cfg(feature = "deserialize")]
738impl<'de> serde::Deserialize<'de> for ListPaymentMethodsCustomerType {
739    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
740        use std::str::FromStr;
741        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
742        Ok(Self::from_str(&s).expect("infallible"))
743    }
744}
745/// Returns a list of PaymentMethods for a given Customer
746#[derive(Clone, Debug, serde::Serialize)]
747pub struct ListPaymentMethodsCustomer {
748    inner: ListPaymentMethodsCustomerBuilder,
749    customer: stripe_shared::CustomerId,
750}
751impl ListPaymentMethodsCustomer {
752    /// Construct a new `ListPaymentMethodsCustomer`.
753    pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
754        Self { customer: customer.into(), inner: ListPaymentMethodsCustomerBuilder::new() }
755    }
756    /// This field indicates whether this payment method can be shown again to its customer in a checkout flow.
757    /// Stripe products such as Checkout and Elements use this field to determine whether a payment method can be shown as a saved payment method in a checkout flow.
758    pub fn allow_redisplay(
759        mut self,
760        allow_redisplay: impl Into<ListPaymentMethodsCustomerAllowRedisplay>,
761    ) -> Self {
762        self.inner.allow_redisplay = Some(allow_redisplay.into());
763        self
764    }
765    /// A cursor for use in pagination.
766    /// `ending_before` is an object ID that defines your place in the list.
767    /// For instance, if you make a list request and receive 100 objects, starting with `obj_bar`, your subsequent call can include `ending_before=obj_bar` in order to fetch the previous page of the list.
768    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
769        self.inner.ending_before = Some(ending_before.into());
770        self
771    }
772    /// Specifies which fields in the response should be expanded.
773    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
774        self.inner.expand = Some(expand.into());
775        self
776    }
777    /// A limit on the number of objects to be returned.
778    /// Limit can range between 1 and 100, and the default is 10.
779    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
780        self.inner.limit = Some(limit.into());
781        self
782    }
783    /// A cursor for use in pagination.
784    /// `starting_after` is an object ID that defines your place in the list.
785    /// For instance, if you make a list request and receive 100 objects, ending with `obj_foo`, your subsequent call can include `starting_after=obj_foo` in order to fetch the next page of the list.
786    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
787        self.inner.starting_after = Some(starting_after.into());
788        self
789    }
790    /// An optional filter on the list, based on the object `type` field.
791    /// Without the filter, the list includes all current and future payment method types.
792    /// If your integration expects only one type of payment method in the response, make sure to provide a type value in the request.
793    pub fn type_(mut self, type_: impl Into<ListPaymentMethodsCustomerType>) -> Self {
794        self.inner.type_ = Some(type_.into());
795        self
796    }
797}
798impl ListPaymentMethodsCustomer {
799    /// Send the request and return the deserialized response.
800    pub async fn send<C: StripeClient>(
801        &self,
802        client: &C,
803    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
804        self.customize().send(client).await
805    }
806
807    /// Send the request and return the deserialized response, blocking until completion.
808    pub fn send_blocking<C: StripeBlockingClient>(
809        &self,
810        client: &C,
811    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
812        self.customize().send_blocking(client)
813    }
814
815    pub fn paginate(
816        &self,
817    ) -> stripe_client_core::ListPaginator<stripe_types::List<stripe_shared::PaymentMethod>> {
818        let customer = &self.customer;
819
820        stripe_client_core::ListPaginator::new_list(
821            format!("/customers/{customer}/payment_methods"),
822            &self.inner,
823        )
824    }
825}
826
827impl StripeRequest for ListPaymentMethodsCustomer {
828    type Output = stripe_types::List<stripe_shared::PaymentMethod>;
829
830    fn build(&self) -> RequestBuilder {
831        let customer = &self.customer;
832        RequestBuilder::new(StripeMethod::Get, format!("/customers/{customer}/payment_methods"))
833            .query(&self.inner)
834    }
835}
836#[derive(Clone, Debug, serde::Serialize)]
837struct RetrievePaymentMethodCustomerBuilder {
838    #[serde(skip_serializing_if = "Option::is_none")]
839    expand: Option<Vec<String>>,
840}
841impl RetrievePaymentMethodCustomerBuilder {
842    fn new() -> Self {
843        Self { expand: None }
844    }
845}
846/// Retrieves a PaymentMethod object for a given Customer.
847#[derive(Clone, Debug, serde::Serialize)]
848pub struct RetrievePaymentMethodCustomer {
849    inner: RetrievePaymentMethodCustomerBuilder,
850    customer: stripe_shared::CustomerId,
851    payment_method: String,
852}
853impl RetrievePaymentMethodCustomer {
854    /// Construct a new `RetrievePaymentMethodCustomer`.
855    pub fn new(
856        customer: impl Into<stripe_shared::CustomerId>,
857        payment_method: impl Into<String>,
858    ) -> Self {
859        Self {
860            customer: customer.into(),
861            payment_method: payment_method.into(),
862            inner: RetrievePaymentMethodCustomerBuilder::new(),
863        }
864    }
865    /// Specifies which fields in the response should be expanded.
866    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
867        self.inner.expand = Some(expand.into());
868        self
869    }
870}
871impl RetrievePaymentMethodCustomer {
872    /// Send the request and return the deserialized response.
873    pub async fn send<C: StripeClient>(
874        &self,
875        client: &C,
876    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
877        self.customize().send(client).await
878    }
879
880    /// Send the request and return the deserialized response, blocking until completion.
881    pub fn send_blocking<C: StripeBlockingClient>(
882        &self,
883        client: &C,
884    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
885        self.customize().send_blocking(client)
886    }
887}
888
889impl StripeRequest for RetrievePaymentMethodCustomer {
890    type Output = stripe_shared::PaymentMethod;
891
892    fn build(&self) -> RequestBuilder {
893        let customer = &self.customer;
894        let payment_method = &self.payment_method;
895        RequestBuilder::new(
896            StripeMethod::Get,
897            format!("/customers/{customer}/payment_methods/{payment_method}"),
898        )
899        .query(&self.inner)
900    }
901}
902#[derive(Clone, Debug, serde::Serialize)]
903struct SearchCustomerBuilder {
904    #[serde(skip_serializing_if = "Option::is_none")]
905    expand: Option<Vec<String>>,
906    #[serde(skip_serializing_if = "Option::is_none")]
907    limit: Option<i64>,
908    #[serde(skip_serializing_if = "Option::is_none")]
909    page: Option<String>,
910    query: String,
911}
912impl SearchCustomerBuilder {
913    fn new(query: impl Into<String>) -> Self {
914        Self { expand: None, limit: None, page: None, query: query.into() }
915    }
916}
917/// Search for customers you’ve previously created using Stripe’s [Search Query Language](https://stripe.com/docs/search#search-query-language).
918/// Don’t use search in read-after-write flows where strict consistency is necessary.
919/// Under normal operating.
920/// conditions, data is searchable in less than a minute.
921/// Occasionally, propagation of new or updated data can be up.
922/// to an hour behind during outages. Search functionality is not available to merchants in India.
923#[derive(Clone, Debug, serde::Serialize)]
924pub struct SearchCustomer {
925    inner: SearchCustomerBuilder,
926}
927impl SearchCustomer {
928    /// Construct a new `SearchCustomer`.
929    pub fn new(query: impl Into<String>) -> Self {
930        Self { inner: SearchCustomerBuilder::new(query.into()) }
931    }
932    /// Specifies which fields in the response should be expanded.
933    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
934        self.inner.expand = Some(expand.into());
935        self
936    }
937    /// A limit on the number of objects to be returned.
938    /// Limit can range between 1 and 100, and the default is 10.
939    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
940        self.inner.limit = Some(limit.into());
941        self
942    }
943    /// A cursor for pagination across multiple pages of results.
944    /// Don't include this parameter on the first call.
945    /// Use the next_page value returned in a previous response to request subsequent results.
946    pub fn page(mut self, page: impl Into<String>) -> Self {
947        self.inner.page = Some(page.into());
948        self
949    }
950}
951impl SearchCustomer {
952    /// Send the request and return the deserialized response.
953    pub async fn send<C: StripeClient>(
954        &self,
955        client: &C,
956    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
957        self.customize().send(client).await
958    }
959
960    /// Send the request and return the deserialized response, blocking until completion.
961    pub fn send_blocking<C: StripeBlockingClient>(
962        &self,
963        client: &C,
964    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
965        self.customize().send_blocking(client)
966    }
967
968    pub fn paginate(
969        &self,
970    ) -> stripe_client_core::ListPaginator<stripe_types::SearchList<stripe_shared::Customer>> {
971        stripe_client_core::ListPaginator::new_search_list("/customers/search", &self.inner)
972    }
973}
974
975impl StripeRequest for SearchCustomer {
976    type Output = stripe_types::SearchList<stripe_shared::Customer>;
977
978    fn build(&self) -> RequestBuilder {
979        RequestBuilder::new(StripeMethod::Get, "/customers/search").query(&self.inner)
980    }
981}
982#[derive(Clone, Debug, serde::Serialize)]
983struct CreateCustomerBuilder {
984    #[serde(skip_serializing_if = "Option::is_none")]
985    address: Option<OptionalFieldsCustomerAddress>,
986    #[serde(skip_serializing_if = "Option::is_none")]
987    balance: Option<i64>,
988    #[serde(skip_serializing_if = "Option::is_none")]
989    business_name: Option<String>,
990    #[serde(skip_serializing_if = "Option::is_none")]
991    cash_balance: Option<CreateCustomerCashBalance>,
992    #[serde(skip_serializing_if = "Option::is_none")]
993    description: Option<String>,
994    #[serde(skip_serializing_if = "Option::is_none")]
995    email: Option<String>,
996    #[serde(skip_serializing_if = "Option::is_none")]
997    expand: Option<Vec<String>>,
998    #[serde(skip_serializing_if = "Option::is_none")]
999    individual_name: Option<String>,
1000    #[serde(skip_serializing_if = "Option::is_none")]
1001    invoice_prefix: Option<String>,
1002    #[serde(skip_serializing_if = "Option::is_none")]
1003    invoice_settings: Option<CreateCustomerInvoiceSettings>,
1004    #[serde(skip_serializing_if = "Option::is_none")]
1005    metadata: Option<std::collections::HashMap<String, String>>,
1006    #[serde(skip_serializing_if = "Option::is_none")]
1007    name: Option<String>,
1008    #[serde(skip_serializing_if = "Option::is_none")]
1009    next_invoice_sequence: Option<i64>,
1010    #[serde(skip_serializing_if = "Option::is_none")]
1011    payment_method: Option<String>,
1012    #[serde(skip_serializing_if = "Option::is_none")]
1013    phone: Option<String>,
1014    #[serde(skip_serializing_if = "Option::is_none")]
1015    preferred_locales: Option<Vec<String>>,
1016    #[serde(skip_serializing_if = "Option::is_none")]
1017    shipping: Option<CustomerShipping>,
1018    #[serde(skip_serializing_if = "Option::is_none")]
1019    source: Option<String>,
1020    #[serde(skip_serializing_if = "Option::is_none")]
1021    tax: Option<CreateCustomerTax>,
1022    #[serde(skip_serializing_if = "Option::is_none")]
1023    tax_exempt: Option<stripe_shared::CustomerTaxExempt>,
1024    #[serde(skip_serializing_if = "Option::is_none")]
1025    tax_id_data: Option<Vec<CreateCustomerTaxIdData>>,
1026    #[serde(skip_serializing_if = "Option::is_none")]
1027    test_clock: Option<String>,
1028    #[serde(skip_serializing_if = "Option::is_none")]
1029    validate: Option<bool>,
1030}
1031impl CreateCustomerBuilder {
1032    fn new() -> Self {
1033        Self {
1034            address: None,
1035            balance: None,
1036            business_name: None,
1037            cash_balance: None,
1038            description: None,
1039            email: None,
1040            expand: None,
1041            individual_name: None,
1042            invoice_prefix: None,
1043            invoice_settings: None,
1044            metadata: None,
1045            name: None,
1046            next_invoice_sequence: None,
1047            payment_method: None,
1048            phone: None,
1049            preferred_locales: None,
1050            shipping: None,
1051            source: None,
1052            tax: None,
1053            tax_exempt: None,
1054            tax_id_data: None,
1055            test_clock: None,
1056            validate: None,
1057        }
1058    }
1059}
1060/// Balance information and default balance settings for this customer.
1061#[derive(Clone, Debug, serde::Serialize)]
1062pub struct CreateCustomerCashBalance {
1063    /// Settings controlling the behavior of the customer's cash balance,
1064    /// such as reconciliation of funds received.
1065    #[serde(skip_serializing_if = "Option::is_none")]
1066    pub settings: Option<CreateCustomerCashBalanceSettings>,
1067}
1068impl CreateCustomerCashBalance {
1069    pub fn new() -> Self {
1070        Self { settings: None }
1071    }
1072}
1073impl Default for CreateCustomerCashBalance {
1074    fn default() -> Self {
1075        Self::new()
1076    }
1077}
1078/// Settings controlling the behavior of the customer's cash balance,
1079/// such as reconciliation of funds received.
1080#[derive(Clone, Debug, serde::Serialize)]
1081pub struct CreateCustomerCashBalanceSettings {
1082    /// Controls how funds transferred by the customer are applied to payment intents and invoices.
1083    /// Valid options are `automatic`, `manual`, or `merchant_default`.
1084    /// For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
1085    #[serde(skip_serializing_if = "Option::is_none")]
1086    pub reconciliation_mode: Option<CreateCustomerCashBalanceSettingsReconciliationMode>,
1087}
1088impl CreateCustomerCashBalanceSettings {
1089    pub fn new() -> Self {
1090        Self { reconciliation_mode: None }
1091    }
1092}
1093impl Default for CreateCustomerCashBalanceSettings {
1094    fn default() -> Self {
1095        Self::new()
1096    }
1097}
1098/// Controls how funds transferred by the customer are applied to payment intents and invoices.
1099/// Valid options are `automatic`, `manual`, or `merchant_default`.
1100/// For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
1101#[derive(Clone, Eq, PartialEq)]
1102#[non_exhaustive]
1103pub enum CreateCustomerCashBalanceSettingsReconciliationMode {
1104    Automatic,
1105    Manual,
1106    MerchantDefault,
1107    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1108    Unknown(String),
1109}
1110impl CreateCustomerCashBalanceSettingsReconciliationMode {
1111    pub fn as_str(&self) -> &str {
1112        use CreateCustomerCashBalanceSettingsReconciliationMode::*;
1113        match self {
1114            Automatic => "automatic",
1115            Manual => "manual",
1116            MerchantDefault => "merchant_default",
1117            Unknown(v) => v,
1118        }
1119    }
1120}
1121
1122impl std::str::FromStr for CreateCustomerCashBalanceSettingsReconciliationMode {
1123    type Err = std::convert::Infallible;
1124    fn from_str(s: &str) -> Result<Self, Self::Err> {
1125        use CreateCustomerCashBalanceSettingsReconciliationMode::*;
1126        match s {
1127            "automatic" => Ok(Automatic),
1128            "manual" => Ok(Manual),
1129            "merchant_default" => Ok(MerchantDefault),
1130            v => {
1131                tracing::warn!(
1132                    "Unknown value '{}' for enum '{}'",
1133                    v,
1134                    "CreateCustomerCashBalanceSettingsReconciliationMode"
1135                );
1136                Ok(Unknown(v.to_owned()))
1137            }
1138        }
1139    }
1140}
1141impl std::fmt::Display for CreateCustomerCashBalanceSettingsReconciliationMode {
1142    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1143        f.write_str(self.as_str())
1144    }
1145}
1146
1147impl std::fmt::Debug for CreateCustomerCashBalanceSettingsReconciliationMode {
1148    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1149        f.write_str(self.as_str())
1150    }
1151}
1152impl serde::Serialize for CreateCustomerCashBalanceSettingsReconciliationMode {
1153    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1154    where
1155        S: serde::Serializer,
1156    {
1157        serializer.serialize_str(self.as_str())
1158    }
1159}
1160#[cfg(feature = "deserialize")]
1161impl<'de> serde::Deserialize<'de> for CreateCustomerCashBalanceSettingsReconciliationMode {
1162    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1163        use std::str::FromStr;
1164        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1165        Ok(Self::from_str(&s).expect("infallible"))
1166    }
1167}
1168/// Default invoice settings for this customer.
1169#[derive(Clone, Debug, serde::Serialize)]
1170pub struct CreateCustomerInvoiceSettings {
1171    /// The list of up to 4 default custom fields to be displayed on invoices for this customer.
1172    /// When updating, pass an empty string to remove previously-defined fields.
1173    #[serde(skip_serializing_if = "Option::is_none")]
1174    pub custom_fields: Option<Vec<CustomFieldParams>>,
1175    /// ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices.
1176    #[serde(skip_serializing_if = "Option::is_none")]
1177    pub default_payment_method: Option<String>,
1178    /// Default footer to be displayed on invoices for this customer.
1179    #[serde(skip_serializing_if = "Option::is_none")]
1180    pub footer: Option<String>,
1181    /// Default options for invoice PDF rendering for this customer.
1182    #[serde(skip_serializing_if = "Option::is_none")]
1183    pub rendering_options: Option<CreateCustomerInvoiceSettingsRenderingOptions>,
1184}
1185impl CreateCustomerInvoiceSettings {
1186    pub fn new() -> Self {
1187        Self {
1188            custom_fields: None,
1189            default_payment_method: None,
1190            footer: None,
1191            rendering_options: None,
1192        }
1193    }
1194}
1195impl Default for CreateCustomerInvoiceSettings {
1196    fn default() -> Self {
1197        Self::new()
1198    }
1199}
1200/// Default options for invoice PDF rendering for this customer.
1201#[derive(Clone, Debug, serde::Serialize)]
1202pub struct CreateCustomerInvoiceSettingsRenderingOptions {
1203    /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
1204    /// One of `exclude_tax` or `include_inclusive_tax`.
1205    /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts.
1206    /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts.
1207    #[serde(skip_serializing_if = "Option::is_none")]
1208    pub amount_tax_display: Option<CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay>,
1209    /// ID of the invoice rendering template to use for future invoices.
1210    #[serde(skip_serializing_if = "Option::is_none")]
1211    pub template: Option<String>,
1212}
1213impl CreateCustomerInvoiceSettingsRenderingOptions {
1214    pub fn new() -> Self {
1215        Self { amount_tax_display: None, template: None }
1216    }
1217}
1218impl Default for CreateCustomerInvoiceSettingsRenderingOptions {
1219    fn default() -> Self {
1220        Self::new()
1221    }
1222}
1223/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
1224/// One of `exclude_tax` or `include_inclusive_tax`.
1225/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts.
1226/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts.
1227#[derive(Clone, Eq, PartialEq)]
1228#[non_exhaustive]
1229pub enum CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
1230    ExcludeTax,
1231    IncludeInclusiveTax,
1232    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1233    Unknown(String),
1234}
1235impl CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
1236    pub fn as_str(&self) -> &str {
1237        use CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*;
1238        match self {
1239            ExcludeTax => "exclude_tax",
1240            IncludeInclusiveTax => "include_inclusive_tax",
1241            Unknown(v) => v,
1242        }
1243    }
1244}
1245
1246impl std::str::FromStr for CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
1247    type Err = std::convert::Infallible;
1248    fn from_str(s: &str) -> Result<Self, Self::Err> {
1249        use CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*;
1250        match s {
1251            "exclude_tax" => Ok(ExcludeTax),
1252            "include_inclusive_tax" => Ok(IncludeInclusiveTax),
1253            v => {
1254                tracing::warn!(
1255                    "Unknown value '{}' for enum '{}'",
1256                    v,
1257                    "CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay"
1258                );
1259                Ok(Unknown(v.to_owned()))
1260            }
1261        }
1262    }
1263}
1264impl std::fmt::Display for CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
1265    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1266        f.write_str(self.as_str())
1267    }
1268}
1269
1270impl std::fmt::Debug for CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
1271    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1272        f.write_str(self.as_str())
1273    }
1274}
1275impl serde::Serialize for CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
1276    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1277    where
1278        S: serde::Serializer,
1279    {
1280        serializer.serialize_str(self.as_str())
1281    }
1282}
1283#[cfg(feature = "deserialize")]
1284impl<'de> serde::Deserialize<'de>
1285    for CreateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay
1286{
1287    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1288        use std::str::FromStr;
1289        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1290        Ok(Self::from_str(&s).expect("infallible"))
1291    }
1292}
1293/// Tax details about the customer.
1294#[derive(Clone, Debug, serde::Serialize)]
1295pub struct CreateCustomerTax {
1296    /// A recent IP address of the customer used for tax reporting and tax location inference.
1297    /// Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated.
1298    /// We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
1299    #[serde(skip_serializing_if = "Option::is_none")]
1300    pub ip_address: Option<String>,
1301    /// A flag that indicates when Stripe should validate the customer tax location.
1302    /// Defaults to `deferred`.
1303    #[serde(skip_serializing_if = "Option::is_none")]
1304    pub validate_location: Option<CreateCustomerTaxValidateLocation>,
1305}
1306impl CreateCustomerTax {
1307    pub fn new() -> Self {
1308        Self { ip_address: None, validate_location: None }
1309    }
1310}
1311impl Default for CreateCustomerTax {
1312    fn default() -> Self {
1313        Self::new()
1314    }
1315}
1316/// A flag that indicates when Stripe should validate the customer tax location.
1317/// Defaults to `deferred`.
1318#[derive(Clone, Eq, PartialEq)]
1319#[non_exhaustive]
1320pub enum CreateCustomerTaxValidateLocation {
1321    Deferred,
1322    Immediately,
1323    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1324    Unknown(String),
1325}
1326impl CreateCustomerTaxValidateLocation {
1327    pub fn as_str(&self) -> &str {
1328        use CreateCustomerTaxValidateLocation::*;
1329        match self {
1330            Deferred => "deferred",
1331            Immediately => "immediately",
1332            Unknown(v) => v,
1333        }
1334    }
1335}
1336
1337impl std::str::FromStr for CreateCustomerTaxValidateLocation {
1338    type Err = std::convert::Infallible;
1339    fn from_str(s: &str) -> Result<Self, Self::Err> {
1340        use CreateCustomerTaxValidateLocation::*;
1341        match s {
1342            "deferred" => Ok(Deferred),
1343            "immediately" => Ok(Immediately),
1344            v => {
1345                tracing::warn!(
1346                    "Unknown value '{}' for enum '{}'",
1347                    v,
1348                    "CreateCustomerTaxValidateLocation"
1349                );
1350                Ok(Unknown(v.to_owned()))
1351            }
1352        }
1353    }
1354}
1355impl std::fmt::Display for CreateCustomerTaxValidateLocation {
1356    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1357        f.write_str(self.as_str())
1358    }
1359}
1360
1361impl std::fmt::Debug for CreateCustomerTaxValidateLocation {
1362    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1363        f.write_str(self.as_str())
1364    }
1365}
1366impl serde::Serialize for CreateCustomerTaxValidateLocation {
1367    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1368    where
1369        S: serde::Serializer,
1370    {
1371        serializer.serialize_str(self.as_str())
1372    }
1373}
1374#[cfg(feature = "deserialize")]
1375impl<'de> serde::Deserialize<'de> for CreateCustomerTaxValidateLocation {
1376    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1377        use std::str::FromStr;
1378        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1379        Ok(Self::from_str(&s).expect("infallible"))
1380    }
1381}
1382/// The customer's tax IDs.
1383#[derive(Clone, Debug, serde::Serialize)]
1384pub struct CreateCustomerTaxIdData {
1385    /// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `al_tin`, `am_tin`, `ao_tin`, `ar_cuit`, `au_abn`, `au_arn`, `aw_tin`, `az_tin`, `ba_tin`, `bb_tin`, `bd_bin`, `bf_ifu`, `bg_uic`, `bh_vat`, `bj_ifu`, `bo_tin`, `br_cnpj`, `br_cpf`, `bs_tin`, `by_tin`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `cd_nif`, `ch_uid`, `ch_vat`, `cl_tin`, `cm_niu`, `cn_tin`, `co_nit`, `cr_tin`, `cv_nif`, `de_stn`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `et_tin`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `gn_nif`, `hk_br`, `hr_oib`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kg_tin`, `kh_tin`, `kr_brn`, `kz_bin`, `la_tin`, `li_uid`, `li_vat`, `ma_vat`, `md_vat`, `me_pib`, `mk_vat`, `mr_nif`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `ng_tin`, `no_vat`, `no_voec`, `np_pan`, `nz_gst`, `om_vat`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sn_ninea`, `sr_fin`, `sv_nit`, `th_vat`, `tj_tin`, `tr_tin`, `tw_vat`, `tz_vat`, `ua_vat`, `ug_tin`, `us_ein`, `uy_ruc`, `uz_tin`, `uz_vat`, `ve_rif`, `vn_tin`, `za_vat`, `zm_tin`, or `zw_tin`.
1386    #[serde(rename = "type")]
1387    pub type_: CreateCustomerTaxIdDataType,
1388    /// Value of the tax ID.
1389    pub value: String,
1390}
1391impl CreateCustomerTaxIdData {
1392    pub fn new(type_: impl Into<CreateCustomerTaxIdDataType>, value: impl Into<String>) -> Self {
1393        Self { type_: type_.into(), value: value.into() }
1394    }
1395}
1396/// Type of the tax ID, one of `ad_nrt`, `ae_trn`, `al_tin`, `am_tin`, `ao_tin`, `ar_cuit`, `au_abn`, `au_arn`, `aw_tin`, `az_tin`, `ba_tin`, `bb_tin`, `bd_bin`, `bf_ifu`, `bg_uic`, `bh_vat`, `bj_ifu`, `bo_tin`, `br_cnpj`, `br_cpf`, `bs_tin`, `by_tin`, `ca_bn`, `ca_gst_hst`, `ca_pst_bc`, `ca_pst_mb`, `ca_pst_sk`, `ca_qst`, `cd_nif`, `ch_uid`, `ch_vat`, `cl_tin`, `cm_niu`, `cn_tin`, `co_nit`, `cr_tin`, `cv_nif`, `de_stn`, `do_rcn`, `ec_ruc`, `eg_tin`, `es_cif`, `et_tin`, `eu_oss_vat`, `eu_vat`, `gb_vat`, `ge_vat`, `gn_nif`, `hk_br`, `hr_oib`, `hu_tin`, `id_npwp`, `il_vat`, `in_gst`, `is_vat`, `jp_cn`, `jp_rn`, `jp_trn`, `ke_pin`, `kg_tin`, `kh_tin`, `kr_brn`, `kz_bin`, `la_tin`, `li_uid`, `li_vat`, `ma_vat`, `md_vat`, `me_pib`, `mk_vat`, `mr_nif`, `mx_rfc`, `my_frp`, `my_itn`, `my_sst`, `ng_tin`, `no_vat`, `no_voec`, `np_pan`, `nz_gst`, `om_vat`, `pe_ruc`, `ph_tin`, `ro_tin`, `rs_pib`, `ru_inn`, `ru_kpp`, `sa_vat`, `sg_gst`, `sg_uen`, `si_tin`, `sn_ninea`, `sr_fin`, `sv_nit`, `th_vat`, `tj_tin`, `tr_tin`, `tw_vat`, `tz_vat`, `ua_vat`, `ug_tin`, `us_ein`, `uy_ruc`, `uz_tin`, `uz_vat`, `ve_rif`, `vn_tin`, `za_vat`, `zm_tin`, or `zw_tin`.
1397#[derive(Clone, Eq, PartialEq)]
1398#[non_exhaustive]
1399pub enum CreateCustomerTaxIdDataType {
1400    AdNrt,
1401    AeTrn,
1402    AlTin,
1403    AmTin,
1404    AoTin,
1405    ArCuit,
1406    AuAbn,
1407    AuArn,
1408    AwTin,
1409    AzTin,
1410    BaTin,
1411    BbTin,
1412    BdBin,
1413    BfIfu,
1414    BgUic,
1415    BhVat,
1416    BjIfu,
1417    BoTin,
1418    BrCnpj,
1419    BrCpf,
1420    BsTin,
1421    ByTin,
1422    CaBn,
1423    CaGstHst,
1424    CaPstBc,
1425    CaPstMb,
1426    CaPstSk,
1427    CaQst,
1428    CdNif,
1429    ChUid,
1430    ChVat,
1431    ClTin,
1432    CmNiu,
1433    CnTin,
1434    CoNit,
1435    CrTin,
1436    CvNif,
1437    DeStn,
1438    DoRcn,
1439    EcRuc,
1440    EgTin,
1441    EsCif,
1442    EtTin,
1443    EuOssVat,
1444    EuVat,
1445    GbVat,
1446    GeVat,
1447    GnNif,
1448    HkBr,
1449    HrOib,
1450    HuTin,
1451    IdNpwp,
1452    IlVat,
1453    InGst,
1454    IsVat,
1455    JpCn,
1456    JpRn,
1457    JpTrn,
1458    KePin,
1459    KgTin,
1460    KhTin,
1461    KrBrn,
1462    KzBin,
1463    LaTin,
1464    LiUid,
1465    LiVat,
1466    MaVat,
1467    MdVat,
1468    MePib,
1469    MkVat,
1470    MrNif,
1471    MxRfc,
1472    MyFrp,
1473    MyItn,
1474    MySst,
1475    NgTin,
1476    NoVat,
1477    NoVoec,
1478    NpPan,
1479    NzGst,
1480    OmVat,
1481    PeRuc,
1482    PhTin,
1483    RoTin,
1484    RsPib,
1485    RuInn,
1486    RuKpp,
1487    SaVat,
1488    SgGst,
1489    SgUen,
1490    SiTin,
1491    SnNinea,
1492    SrFin,
1493    SvNit,
1494    ThVat,
1495    TjTin,
1496    TrTin,
1497    TwVat,
1498    TzVat,
1499    UaVat,
1500    UgTin,
1501    UsEin,
1502    UyRuc,
1503    UzTin,
1504    UzVat,
1505    VeRif,
1506    VnTin,
1507    ZaVat,
1508    ZmTin,
1509    ZwTin,
1510    /// An unrecognized value from Stripe. Should not be used as a request parameter.
1511    Unknown(String),
1512}
1513impl CreateCustomerTaxIdDataType {
1514    pub fn as_str(&self) -> &str {
1515        use CreateCustomerTaxIdDataType::*;
1516        match self {
1517            AdNrt => "ad_nrt",
1518            AeTrn => "ae_trn",
1519            AlTin => "al_tin",
1520            AmTin => "am_tin",
1521            AoTin => "ao_tin",
1522            ArCuit => "ar_cuit",
1523            AuAbn => "au_abn",
1524            AuArn => "au_arn",
1525            AwTin => "aw_tin",
1526            AzTin => "az_tin",
1527            BaTin => "ba_tin",
1528            BbTin => "bb_tin",
1529            BdBin => "bd_bin",
1530            BfIfu => "bf_ifu",
1531            BgUic => "bg_uic",
1532            BhVat => "bh_vat",
1533            BjIfu => "bj_ifu",
1534            BoTin => "bo_tin",
1535            BrCnpj => "br_cnpj",
1536            BrCpf => "br_cpf",
1537            BsTin => "bs_tin",
1538            ByTin => "by_tin",
1539            CaBn => "ca_bn",
1540            CaGstHst => "ca_gst_hst",
1541            CaPstBc => "ca_pst_bc",
1542            CaPstMb => "ca_pst_mb",
1543            CaPstSk => "ca_pst_sk",
1544            CaQst => "ca_qst",
1545            CdNif => "cd_nif",
1546            ChUid => "ch_uid",
1547            ChVat => "ch_vat",
1548            ClTin => "cl_tin",
1549            CmNiu => "cm_niu",
1550            CnTin => "cn_tin",
1551            CoNit => "co_nit",
1552            CrTin => "cr_tin",
1553            CvNif => "cv_nif",
1554            DeStn => "de_stn",
1555            DoRcn => "do_rcn",
1556            EcRuc => "ec_ruc",
1557            EgTin => "eg_tin",
1558            EsCif => "es_cif",
1559            EtTin => "et_tin",
1560            EuOssVat => "eu_oss_vat",
1561            EuVat => "eu_vat",
1562            GbVat => "gb_vat",
1563            GeVat => "ge_vat",
1564            GnNif => "gn_nif",
1565            HkBr => "hk_br",
1566            HrOib => "hr_oib",
1567            HuTin => "hu_tin",
1568            IdNpwp => "id_npwp",
1569            IlVat => "il_vat",
1570            InGst => "in_gst",
1571            IsVat => "is_vat",
1572            JpCn => "jp_cn",
1573            JpRn => "jp_rn",
1574            JpTrn => "jp_trn",
1575            KePin => "ke_pin",
1576            KgTin => "kg_tin",
1577            KhTin => "kh_tin",
1578            KrBrn => "kr_brn",
1579            KzBin => "kz_bin",
1580            LaTin => "la_tin",
1581            LiUid => "li_uid",
1582            LiVat => "li_vat",
1583            MaVat => "ma_vat",
1584            MdVat => "md_vat",
1585            MePib => "me_pib",
1586            MkVat => "mk_vat",
1587            MrNif => "mr_nif",
1588            MxRfc => "mx_rfc",
1589            MyFrp => "my_frp",
1590            MyItn => "my_itn",
1591            MySst => "my_sst",
1592            NgTin => "ng_tin",
1593            NoVat => "no_vat",
1594            NoVoec => "no_voec",
1595            NpPan => "np_pan",
1596            NzGst => "nz_gst",
1597            OmVat => "om_vat",
1598            PeRuc => "pe_ruc",
1599            PhTin => "ph_tin",
1600            RoTin => "ro_tin",
1601            RsPib => "rs_pib",
1602            RuInn => "ru_inn",
1603            RuKpp => "ru_kpp",
1604            SaVat => "sa_vat",
1605            SgGst => "sg_gst",
1606            SgUen => "sg_uen",
1607            SiTin => "si_tin",
1608            SnNinea => "sn_ninea",
1609            SrFin => "sr_fin",
1610            SvNit => "sv_nit",
1611            ThVat => "th_vat",
1612            TjTin => "tj_tin",
1613            TrTin => "tr_tin",
1614            TwVat => "tw_vat",
1615            TzVat => "tz_vat",
1616            UaVat => "ua_vat",
1617            UgTin => "ug_tin",
1618            UsEin => "us_ein",
1619            UyRuc => "uy_ruc",
1620            UzTin => "uz_tin",
1621            UzVat => "uz_vat",
1622            VeRif => "ve_rif",
1623            VnTin => "vn_tin",
1624            ZaVat => "za_vat",
1625            ZmTin => "zm_tin",
1626            ZwTin => "zw_tin",
1627            Unknown(v) => v,
1628        }
1629    }
1630}
1631
1632impl std::str::FromStr for CreateCustomerTaxIdDataType {
1633    type Err = std::convert::Infallible;
1634    fn from_str(s: &str) -> Result<Self, Self::Err> {
1635        use CreateCustomerTaxIdDataType::*;
1636        match s {
1637            "ad_nrt" => Ok(AdNrt),
1638            "ae_trn" => Ok(AeTrn),
1639            "al_tin" => Ok(AlTin),
1640            "am_tin" => Ok(AmTin),
1641            "ao_tin" => Ok(AoTin),
1642            "ar_cuit" => Ok(ArCuit),
1643            "au_abn" => Ok(AuAbn),
1644            "au_arn" => Ok(AuArn),
1645            "aw_tin" => Ok(AwTin),
1646            "az_tin" => Ok(AzTin),
1647            "ba_tin" => Ok(BaTin),
1648            "bb_tin" => Ok(BbTin),
1649            "bd_bin" => Ok(BdBin),
1650            "bf_ifu" => Ok(BfIfu),
1651            "bg_uic" => Ok(BgUic),
1652            "bh_vat" => Ok(BhVat),
1653            "bj_ifu" => Ok(BjIfu),
1654            "bo_tin" => Ok(BoTin),
1655            "br_cnpj" => Ok(BrCnpj),
1656            "br_cpf" => Ok(BrCpf),
1657            "bs_tin" => Ok(BsTin),
1658            "by_tin" => Ok(ByTin),
1659            "ca_bn" => Ok(CaBn),
1660            "ca_gst_hst" => Ok(CaGstHst),
1661            "ca_pst_bc" => Ok(CaPstBc),
1662            "ca_pst_mb" => Ok(CaPstMb),
1663            "ca_pst_sk" => Ok(CaPstSk),
1664            "ca_qst" => Ok(CaQst),
1665            "cd_nif" => Ok(CdNif),
1666            "ch_uid" => Ok(ChUid),
1667            "ch_vat" => Ok(ChVat),
1668            "cl_tin" => Ok(ClTin),
1669            "cm_niu" => Ok(CmNiu),
1670            "cn_tin" => Ok(CnTin),
1671            "co_nit" => Ok(CoNit),
1672            "cr_tin" => Ok(CrTin),
1673            "cv_nif" => Ok(CvNif),
1674            "de_stn" => Ok(DeStn),
1675            "do_rcn" => Ok(DoRcn),
1676            "ec_ruc" => Ok(EcRuc),
1677            "eg_tin" => Ok(EgTin),
1678            "es_cif" => Ok(EsCif),
1679            "et_tin" => Ok(EtTin),
1680            "eu_oss_vat" => Ok(EuOssVat),
1681            "eu_vat" => Ok(EuVat),
1682            "gb_vat" => Ok(GbVat),
1683            "ge_vat" => Ok(GeVat),
1684            "gn_nif" => Ok(GnNif),
1685            "hk_br" => Ok(HkBr),
1686            "hr_oib" => Ok(HrOib),
1687            "hu_tin" => Ok(HuTin),
1688            "id_npwp" => Ok(IdNpwp),
1689            "il_vat" => Ok(IlVat),
1690            "in_gst" => Ok(InGst),
1691            "is_vat" => Ok(IsVat),
1692            "jp_cn" => Ok(JpCn),
1693            "jp_rn" => Ok(JpRn),
1694            "jp_trn" => Ok(JpTrn),
1695            "ke_pin" => Ok(KePin),
1696            "kg_tin" => Ok(KgTin),
1697            "kh_tin" => Ok(KhTin),
1698            "kr_brn" => Ok(KrBrn),
1699            "kz_bin" => Ok(KzBin),
1700            "la_tin" => Ok(LaTin),
1701            "li_uid" => Ok(LiUid),
1702            "li_vat" => Ok(LiVat),
1703            "ma_vat" => Ok(MaVat),
1704            "md_vat" => Ok(MdVat),
1705            "me_pib" => Ok(MePib),
1706            "mk_vat" => Ok(MkVat),
1707            "mr_nif" => Ok(MrNif),
1708            "mx_rfc" => Ok(MxRfc),
1709            "my_frp" => Ok(MyFrp),
1710            "my_itn" => Ok(MyItn),
1711            "my_sst" => Ok(MySst),
1712            "ng_tin" => Ok(NgTin),
1713            "no_vat" => Ok(NoVat),
1714            "no_voec" => Ok(NoVoec),
1715            "np_pan" => Ok(NpPan),
1716            "nz_gst" => Ok(NzGst),
1717            "om_vat" => Ok(OmVat),
1718            "pe_ruc" => Ok(PeRuc),
1719            "ph_tin" => Ok(PhTin),
1720            "ro_tin" => Ok(RoTin),
1721            "rs_pib" => Ok(RsPib),
1722            "ru_inn" => Ok(RuInn),
1723            "ru_kpp" => Ok(RuKpp),
1724            "sa_vat" => Ok(SaVat),
1725            "sg_gst" => Ok(SgGst),
1726            "sg_uen" => Ok(SgUen),
1727            "si_tin" => Ok(SiTin),
1728            "sn_ninea" => Ok(SnNinea),
1729            "sr_fin" => Ok(SrFin),
1730            "sv_nit" => Ok(SvNit),
1731            "th_vat" => Ok(ThVat),
1732            "tj_tin" => Ok(TjTin),
1733            "tr_tin" => Ok(TrTin),
1734            "tw_vat" => Ok(TwVat),
1735            "tz_vat" => Ok(TzVat),
1736            "ua_vat" => Ok(UaVat),
1737            "ug_tin" => Ok(UgTin),
1738            "us_ein" => Ok(UsEin),
1739            "uy_ruc" => Ok(UyRuc),
1740            "uz_tin" => Ok(UzTin),
1741            "uz_vat" => Ok(UzVat),
1742            "ve_rif" => Ok(VeRif),
1743            "vn_tin" => Ok(VnTin),
1744            "za_vat" => Ok(ZaVat),
1745            "zm_tin" => Ok(ZmTin),
1746            "zw_tin" => Ok(ZwTin),
1747            v => {
1748                tracing::warn!(
1749                    "Unknown value '{}' for enum '{}'",
1750                    v,
1751                    "CreateCustomerTaxIdDataType"
1752                );
1753                Ok(Unknown(v.to_owned()))
1754            }
1755        }
1756    }
1757}
1758impl std::fmt::Display for CreateCustomerTaxIdDataType {
1759    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1760        f.write_str(self.as_str())
1761    }
1762}
1763
1764impl std::fmt::Debug for CreateCustomerTaxIdDataType {
1765    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
1766        f.write_str(self.as_str())
1767    }
1768}
1769impl serde::Serialize for CreateCustomerTaxIdDataType {
1770    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
1771    where
1772        S: serde::Serializer,
1773    {
1774        serializer.serialize_str(self.as_str())
1775    }
1776}
1777#[cfg(feature = "deserialize")]
1778impl<'de> serde::Deserialize<'de> for CreateCustomerTaxIdDataType {
1779    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
1780        use std::str::FromStr;
1781        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
1782        Ok(Self::from_str(&s).expect("infallible"))
1783    }
1784}
1785/// Creates a new customer object.
1786#[derive(Clone, Debug, serde::Serialize)]
1787pub struct CreateCustomer {
1788    inner: CreateCustomerBuilder,
1789}
1790impl CreateCustomer {
1791    /// Construct a new `CreateCustomer`.
1792    pub fn new() -> Self {
1793        Self { inner: CreateCustomerBuilder::new() }
1794    }
1795    /// The customer's address.
1796    pub fn address(mut self, address: impl Into<OptionalFieldsCustomerAddress>) -> Self {
1797        self.inner.address = Some(address.into());
1798        self
1799    }
1800    /// An integer amount in cents (or local equivalent) that represents the customer's current balance, which affect the customer's future invoices.
1801    /// A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice.
1802    pub fn balance(mut self, balance: impl Into<i64>) -> Self {
1803        self.inner.balance = Some(balance.into());
1804        self
1805    }
1806    /// The customer's business name. This may be up to *150 characters*.
1807    pub fn business_name(mut self, business_name: impl Into<String>) -> Self {
1808        self.inner.business_name = Some(business_name.into());
1809        self
1810    }
1811    /// Balance information and default balance settings for this customer.
1812    pub fn cash_balance(mut self, cash_balance: impl Into<CreateCustomerCashBalance>) -> Self {
1813        self.inner.cash_balance = Some(cash_balance.into());
1814        self
1815    }
1816    /// An arbitrary string that you can attach to a customer object.
1817    /// It is displayed alongside the customer in the dashboard.
1818    pub fn description(mut self, description: impl Into<String>) -> Self {
1819        self.inner.description = Some(description.into());
1820        self
1821    }
1822    /// Customer's email address.
1823    /// It's displayed alongside the customer in your dashboard and can be useful for searching and tracking.
1824    /// This may be up to *512 characters*.
1825    pub fn email(mut self, email: impl Into<String>) -> Self {
1826        self.inner.email = Some(email.into());
1827        self
1828    }
1829    /// Specifies which fields in the response should be expanded.
1830    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
1831        self.inner.expand = Some(expand.into());
1832        self
1833    }
1834    /// The customer's full name. This may be up to *150 characters*.
1835    pub fn individual_name(mut self, individual_name: impl Into<String>) -> Self {
1836        self.inner.individual_name = Some(individual_name.into());
1837        self
1838    }
1839    /// The prefix for the customer used to generate unique invoice numbers.
1840    /// Must be 3–12 uppercase letters or numbers.
1841    pub fn invoice_prefix(mut self, invoice_prefix: impl Into<String>) -> Self {
1842        self.inner.invoice_prefix = Some(invoice_prefix.into());
1843        self
1844    }
1845    /// Default invoice settings for this customer.
1846    pub fn invoice_settings(
1847        mut self,
1848        invoice_settings: impl Into<CreateCustomerInvoiceSettings>,
1849    ) -> Self {
1850        self.inner.invoice_settings = Some(invoice_settings.into());
1851        self
1852    }
1853    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
1854    /// This can be useful for storing additional information about the object in a structured format.
1855    /// Individual keys can be unset by posting an empty value to them.
1856    /// All keys can be unset by posting an empty value to `metadata`.
1857    pub fn metadata(
1858        mut self,
1859        metadata: impl Into<std::collections::HashMap<String, String>>,
1860    ) -> Self {
1861        self.inner.metadata = Some(metadata.into());
1862        self
1863    }
1864    /// The customer's full name or business name.
1865    pub fn name(mut self, name: impl Into<String>) -> Self {
1866        self.inner.name = Some(name.into());
1867        self
1868    }
1869    /// The sequence to be used on the customer's next invoice. Defaults to 1.
1870    pub fn next_invoice_sequence(mut self, next_invoice_sequence: impl Into<i64>) -> Self {
1871        self.inner.next_invoice_sequence = Some(next_invoice_sequence.into());
1872        self
1873    }
1874    pub fn payment_method(mut self, payment_method: impl Into<String>) -> Self {
1875        self.inner.payment_method = Some(payment_method.into());
1876        self
1877    }
1878    /// The customer's phone number.
1879    pub fn phone(mut self, phone: impl Into<String>) -> Self {
1880        self.inner.phone = Some(phone.into());
1881        self
1882    }
1883    /// Customer's preferred languages, ordered by preference.
1884    pub fn preferred_locales(mut self, preferred_locales: impl Into<Vec<String>>) -> Self {
1885        self.inner.preferred_locales = Some(preferred_locales.into());
1886        self
1887    }
1888    /// The customer's shipping information. Appears on invoices emailed to this customer.
1889    pub fn shipping(mut self, shipping: impl Into<CustomerShipping>) -> Self {
1890        self.inner.shipping = Some(shipping.into());
1891        self
1892    }
1893    pub fn source(mut self, source: impl Into<String>) -> Self {
1894        self.inner.source = Some(source.into());
1895        self
1896    }
1897    /// Tax details about the customer.
1898    pub fn tax(mut self, tax: impl Into<CreateCustomerTax>) -> Self {
1899        self.inner.tax = Some(tax.into());
1900        self
1901    }
1902    /// The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
1903    pub fn tax_exempt(mut self, tax_exempt: impl Into<stripe_shared::CustomerTaxExempt>) -> Self {
1904        self.inner.tax_exempt = Some(tax_exempt.into());
1905        self
1906    }
1907    /// The customer's tax IDs.
1908    pub fn tax_id_data(mut self, tax_id_data: impl Into<Vec<CreateCustomerTaxIdData>>) -> Self {
1909        self.inner.tax_id_data = Some(tax_id_data.into());
1910        self
1911    }
1912    /// ID of the test clock to attach to the customer.
1913    pub fn test_clock(mut self, test_clock: impl Into<String>) -> Self {
1914        self.inner.test_clock = Some(test_clock.into());
1915        self
1916    }
1917    pub fn validate(mut self, validate: impl Into<bool>) -> Self {
1918        self.inner.validate = Some(validate.into());
1919        self
1920    }
1921}
1922impl Default for CreateCustomer {
1923    fn default() -> Self {
1924        Self::new()
1925    }
1926}
1927impl CreateCustomer {
1928    /// Send the request and return the deserialized response.
1929    pub async fn send<C: StripeClient>(
1930        &self,
1931        client: &C,
1932    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1933        self.customize().send(client).await
1934    }
1935
1936    /// Send the request and return the deserialized response, blocking until completion.
1937    pub fn send_blocking<C: StripeBlockingClient>(
1938        &self,
1939        client: &C,
1940    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
1941        self.customize().send_blocking(client)
1942    }
1943}
1944
1945impl StripeRequest for CreateCustomer {
1946    type Output = stripe_shared::Customer;
1947
1948    fn build(&self) -> RequestBuilder {
1949        RequestBuilder::new(StripeMethod::Post, "/customers").form(&self.inner)
1950    }
1951}
1952#[derive(Clone, Debug, serde::Serialize)]
1953struct UpdateCustomerBuilder {
1954    #[serde(skip_serializing_if = "Option::is_none")]
1955    address: Option<OptionalFieldsCustomerAddress>,
1956    #[serde(skip_serializing_if = "Option::is_none")]
1957    balance: Option<i64>,
1958    #[serde(skip_serializing_if = "Option::is_none")]
1959    business_name: Option<String>,
1960    #[serde(skip_serializing_if = "Option::is_none")]
1961    cash_balance: Option<UpdateCustomerCashBalance>,
1962    #[serde(skip_serializing_if = "Option::is_none")]
1963    default_source: Option<String>,
1964    #[serde(skip_serializing_if = "Option::is_none")]
1965    description: Option<String>,
1966    #[serde(skip_serializing_if = "Option::is_none")]
1967    email: Option<String>,
1968    #[serde(skip_serializing_if = "Option::is_none")]
1969    expand: Option<Vec<String>>,
1970    #[serde(skip_serializing_if = "Option::is_none")]
1971    individual_name: Option<String>,
1972    #[serde(skip_serializing_if = "Option::is_none")]
1973    invoice_prefix: Option<String>,
1974    #[serde(skip_serializing_if = "Option::is_none")]
1975    invoice_settings: Option<UpdateCustomerInvoiceSettings>,
1976    #[serde(skip_serializing_if = "Option::is_none")]
1977    metadata: Option<std::collections::HashMap<String, String>>,
1978    #[serde(skip_serializing_if = "Option::is_none")]
1979    name: Option<String>,
1980    #[serde(skip_serializing_if = "Option::is_none")]
1981    next_invoice_sequence: Option<i64>,
1982    #[serde(skip_serializing_if = "Option::is_none")]
1983    phone: Option<String>,
1984    #[serde(skip_serializing_if = "Option::is_none")]
1985    preferred_locales: Option<Vec<String>>,
1986    #[serde(skip_serializing_if = "Option::is_none")]
1987    shipping: Option<CustomerShipping>,
1988    #[serde(skip_serializing_if = "Option::is_none")]
1989    source: Option<String>,
1990    #[serde(skip_serializing_if = "Option::is_none")]
1991    tax: Option<UpdateCustomerTax>,
1992    #[serde(skip_serializing_if = "Option::is_none")]
1993    tax_exempt: Option<stripe_shared::CustomerTaxExempt>,
1994    #[serde(skip_serializing_if = "Option::is_none")]
1995    validate: Option<bool>,
1996}
1997impl UpdateCustomerBuilder {
1998    fn new() -> Self {
1999        Self {
2000            address: None,
2001            balance: None,
2002            business_name: None,
2003            cash_balance: None,
2004            default_source: None,
2005            description: None,
2006            email: None,
2007            expand: None,
2008            individual_name: None,
2009            invoice_prefix: None,
2010            invoice_settings: None,
2011            metadata: None,
2012            name: None,
2013            next_invoice_sequence: None,
2014            phone: None,
2015            preferred_locales: None,
2016            shipping: None,
2017            source: None,
2018            tax: None,
2019            tax_exempt: None,
2020            validate: None,
2021        }
2022    }
2023}
2024/// Balance information and default balance settings for this customer.
2025#[derive(Clone, Debug, serde::Serialize)]
2026pub struct UpdateCustomerCashBalance {
2027    /// Settings controlling the behavior of the customer's cash balance,
2028    /// such as reconciliation of funds received.
2029    #[serde(skip_serializing_if = "Option::is_none")]
2030    pub settings: Option<UpdateCustomerCashBalanceSettings>,
2031}
2032impl UpdateCustomerCashBalance {
2033    pub fn new() -> Self {
2034        Self { settings: None }
2035    }
2036}
2037impl Default for UpdateCustomerCashBalance {
2038    fn default() -> Self {
2039        Self::new()
2040    }
2041}
2042/// Settings controlling the behavior of the customer's cash balance,
2043/// such as reconciliation of funds received.
2044#[derive(Clone, Debug, serde::Serialize)]
2045pub struct UpdateCustomerCashBalanceSettings {
2046    /// Controls how funds transferred by the customer are applied to payment intents and invoices.
2047    /// Valid options are `automatic`, `manual`, or `merchant_default`.
2048    /// For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
2049    #[serde(skip_serializing_if = "Option::is_none")]
2050    pub reconciliation_mode: Option<UpdateCustomerCashBalanceSettingsReconciliationMode>,
2051}
2052impl UpdateCustomerCashBalanceSettings {
2053    pub fn new() -> Self {
2054        Self { reconciliation_mode: None }
2055    }
2056}
2057impl Default for UpdateCustomerCashBalanceSettings {
2058    fn default() -> Self {
2059        Self::new()
2060    }
2061}
2062/// Controls how funds transferred by the customer are applied to payment intents and invoices.
2063/// Valid options are `automatic`, `manual`, or `merchant_default`.
2064/// For more information about these reconciliation modes, see [Reconciliation](https://stripe.com/docs/payments/customer-balance/reconciliation).
2065#[derive(Clone, Eq, PartialEq)]
2066#[non_exhaustive]
2067pub enum UpdateCustomerCashBalanceSettingsReconciliationMode {
2068    Automatic,
2069    Manual,
2070    MerchantDefault,
2071    /// An unrecognized value from Stripe. Should not be used as a request parameter.
2072    Unknown(String),
2073}
2074impl UpdateCustomerCashBalanceSettingsReconciliationMode {
2075    pub fn as_str(&self) -> &str {
2076        use UpdateCustomerCashBalanceSettingsReconciliationMode::*;
2077        match self {
2078            Automatic => "automatic",
2079            Manual => "manual",
2080            MerchantDefault => "merchant_default",
2081            Unknown(v) => v,
2082        }
2083    }
2084}
2085
2086impl std::str::FromStr for UpdateCustomerCashBalanceSettingsReconciliationMode {
2087    type Err = std::convert::Infallible;
2088    fn from_str(s: &str) -> Result<Self, Self::Err> {
2089        use UpdateCustomerCashBalanceSettingsReconciliationMode::*;
2090        match s {
2091            "automatic" => Ok(Automatic),
2092            "manual" => Ok(Manual),
2093            "merchant_default" => Ok(MerchantDefault),
2094            v => {
2095                tracing::warn!(
2096                    "Unknown value '{}' for enum '{}'",
2097                    v,
2098                    "UpdateCustomerCashBalanceSettingsReconciliationMode"
2099                );
2100                Ok(Unknown(v.to_owned()))
2101            }
2102        }
2103    }
2104}
2105impl std::fmt::Display for UpdateCustomerCashBalanceSettingsReconciliationMode {
2106    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2107        f.write_str(self.as_str())
2108    }
2109}
2110
2111impl std::fmt::Debug for UpdateCustomerCashBalanceSettingsReconciliationMode {
2112    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2113        f.write_str(self.as_str())
2114    }
2115}
2116impl serde::Serialize for UpdateCustomerCashBalanceSettingsReconciliationMode {
2117    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2118    where
2119        S: serde::Serializer,
2120    {
2121        serializer.serialize_str(self.as_str())
2122    }
2123}
2124#[cfg(feature = "deserialize")]
2125impl<'de> serde::Deserialize<'de> for UpdateCustomerCashBalanceSettingsReconciliationMode {
2126    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2127        use std::str::FromStr;
2128        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
2129        Ok(Self::from_str(&s).expect("infallible"))
2130    }
2131}
2132/// Default invoice settings for this customer.
2133#[derive(Clone, Debug, serde::Serialize)]
2134pub struct UpdateCustomerInvoiceSettings {
2135    /// The list of up to 4 default custom fields to be displayed on invoices for this customer.
2136    /// When updating, pass an empty string to remove previously-defined fields.
2137    #[serde(skip_serializing_if = "Option::is_none")]
2138    pub custom_fields: Option<Vec<CustomFieldParams>>,
2139    /// ID of a payment method that's attached to the customer, to be used as the customer's default payment method for subscriptions and invoices.
2140    #[serde(skip_serializing_if = "Option::is_none")]
2141    pub default_payment_method: Option<String>,
2142    /// Default footer to be displayed on invoices for this customer.
2143    #[serde(skip_serializing_if = "Option::is_none")]
2144    pub footer: Option<String>,
2145    /// Default options for invoice PDF rendering for this customer.
2146    #[serde(skip_serializing_if = "Option::is_none")]
2147    pub rendering_options: Option<UpdateCustomerInvoiceSettingsRenderingOptions>,
2148}
2149impl UpdateCustomerInvoiceSettings {
2150    pub fn new() -> Self {
2151        Self {
2152            custom_fields: None,
2153            default_payment_method: None,
2154            footer: None,
2155            rendering_options: None,
2156        }
2157    }
2158}
2159impl Default for UpdateCustomerInvoiceSettings {
2160    fn default() -> Self {
2161        Self::new()
2162    }
2163}
2164/// Default options for invoice PDF rendering for this customer.
2165#[derive(Clone, Debug, serde::Serialize)]
2166pub struct UpdateCustomerInvoiceSettingsRenderingOptions {
2167    /// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
2168    /// One of `exclude_tax` or `include_inclusive_tax`.
2169    /// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts.
2170    /// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts.
2171    #[serde(skip_serializing_if = "Option::is_none")]
2172    pub amount_tax_display: Option<UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay>,
2173    /// ID of the invoice rendering template to use for future invoices.
2174    #[serde(skip_serializing_if = "Option::is_none")]
2175    pub template: Option<String>,
2176}
2177impl UpdateCustomerInvoiceSettingsRenderingOptions {
2178    pub fn new() -> Self {
2179        Self { amount_tax_display: None, template: None }
2180    }
2181}
2182impl Default for UpdateCustomerInvoiceSettingsRenderingOptions {
2183    fn default() -> Self {
2184        Self::new()
2185    }
2186}
2187/// How line-item prices and amounts will be displayed with respect to tax on invoice PDFs.
2188/// One of `exclude_tax` or `include_inclusive_tax`.
2189/// `include_inclusive_tax` will include inclusive tax (and exclude exclusive tax) in invoice PDF amounts.
2190/// `exclude_tax` will exclude all tax (inclusive and exclusive alike) from invoice PDF amounts.
2191#[derive(Clone, Eq, PartialEq)]
2192#[non_exhaustive]
2193pub enum UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
2194    ExcludeTax,
2195    IncludeInclusiveTax,
2196    /// An unrecognized value from Stripe. Should not be used as a request parameter.
2197    Unknown(String),
2198}
2199impl UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
2200    pub fn as_str(&self) -> &str {
2201        use UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*;
2202        match self {
2203            ExcludeTax => "exclude_tax",
2204            IncludeInclusiveTax => "include_inclusive_tax",
2205            Unknown(v) => v,
2206        }
2207    }
2208}
2209
2210impl std::str::FromStr for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
2211    type Err = std::convert::Infallible;
2212    fn from_str(s: &str) -> Result<Self, Self::Err> {
2213        use UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay::*;
2214        match s {
2215            "exclude_tax" => Ok(ExcludeTax),
2216            "include_inclusive_tax" => Ok(IncludeInclusiveTax),
2217            v => {
2218                tracing::warn!(
2219                    "Unknown value '{}' for enum '{}'",
2220                    v,
2221                    "UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay"
2222                );
2223                Ok(Unknown(v.to_owned()))
2224            }
2225        }
2226    }
2227}
2228impl std::fmt::Display for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
2229    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2230        f.write_str(self.as_str())
2231    }
2232}
2233
2234impl std::fmt::Debug for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
2235    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2236        f.write_str(self.as_str())
2237    }
2238}
2239impl serde::Serialize for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay {
2240    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2241    where
2242        S: serde::Serializer,
2243    {
2244        serializer.serialize_str(self.as_str())
2245    }
2246}
2247#[cfg(feature = "deserialize")]
2248impl<'de> serde::Deserialize<'de>
2249    for UpdateCustomerInvoiceSettingsRenderingOptionsAmountTaxDisplay
2250{
2251    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2252        use std::str::FromStr;
2253        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
2254        Ok(Self::from_str(&s).expect("infallible"))
2255    }
2256}
2257/// Tax details about the customer.
2258#[derive(Clone, Debug, serde::Serialize)]
2259pub struct UpdateCustomerTax {
2260    /// A recent IP address of the customer used for tax reporting and tax location inference.
2261    /// Stripe recommends updating the IP address when a new PaymentMethod is attached or the address field on the customer is updated.
2262    /// We recommend against updating this field more frequently since it could result in unexpected tax location/reporting outcomes.
2263    #[serde(skip_serializing_if = "Option::is_none")]
2264    pub ip_address: Option<String>,
2265    /// A flag that indicates when Stripe should validate the customer tax location. Defaults to `auto`.
2266    #[serde(skip_serializing_if = "Option::is_none")]
2267    pub validate_location: Option<UpdateCustomerTaxValidateLocation>,
2268}
2269impl UpdateCustomerTax {
2270    pub fn new() -> Self {
2271        Self { ip_address: None, validate_location: None }
2272    }
2273}
2274impl Default for UpdateCustomerTax {
2275    fn default() -> Self {
2276        Self::new()
2277    }
2278}
2279/// A flag that indicates when Stripe should validate the customer tax location. Defaults to `auto`.
2280#[derive(Clone, Eq, PartialEq)]
2281#[non_exhaustive]
2282pub enum UpdateCustomerTaxValidateLocation {
2283    Auto,
2284    Deferred,
2285    Immediately,
2286    /// An unrecognized value from Stripe. Should not be used as a request parameter.
2287    Unknown(String),
2288}
2289impl UpdateCustomerTaxValidateLocation {
2290    pub fn as_str(&self) -> &str {
2291        use UpdateCustomerTaxValidateLocation::*;
2292        match self {
2293            Auto => "auto",
2294            Deferred => "deferred",
2295            Immediately => "immediately",
2296            Unknown(v) => v,
2297        }
2298    }
2299}
2300
2301impl std::str::FromStr for UpdateCustomerTaxValidateLocation {
2302    type Err = std::convert::Infallible;
2303    fn from_str(s: &str) -> Result<Self, Self::Err> {
2304        use UpdateCustomerTaxValidateLocation::*;
2305        match s {
2306            "auto" => Ok(Auto),
2307            "deferred" => Ok(Deferred),
2308            "immediately" => Ok(Immediately),
2309            v => {
2310                tracing::warn!(
2311                    "Unknown value '{}' for enum '{}'",
2312                    v,
2313                    "UpdateCustomerTaxValidateLocation"
2314                );
2315                Ok(Unknown(v.to_owned()))
2316            }
2317        }
2318    }
2319}
2320impl std::fmt::Display for UpdateCustomerTaxValidateLocation {
2321    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2322        f.write_str(self.as_str())
2323    }
2324}
2325
2326impl std::fmt::Debug for UpdateCustomerTaxValidateLocation {
2327    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2328        f.write_str(self.as_str())
2329    }
2330}
2331impl serde::Serialize for UpdateCustomerTaxValidateLocation {
2332    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2333    where
2334        S: serde::Serializer,
2335    {
2336        serializer.serialize_str(self.as_str())
2337    }
2338}
2339#[cfg(feature = "deserialize")]
2340impl<'de> serde::Deserialize<'de> for UpdateCustomerTaxValidateLocation {
2341    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2342        use std::str::FromStr;
2343        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
2344        Ok(Self::from_str(&s).expect("infallible"))
2345    }
2346}
2347/// Updates the specified customer by setting the values of the parameters passed.
2348/// Any parameters not provided will be left unchanged.
2349/// For example, if you pass the **source** parameter, that becomes the customer’s active source (e.g., a card) to be used for all charges in the future.
2350/// When you update a customer to a new valid card source by passing the **source** parameter: for each of the customer’s current subscriptions, if the subscription bills automatically and is in the `past_due` state, then the latest open invoice for the subscription with automatic collection enabled will be retried.
2351/// This retry will not count as an automatic retry, and will not affect the next regularly scheduled payment for the invoice.
2352/// Changing the **default_source** for a customer will not trigger this behavior.
2353///
2354/// This request accepts mostly the same arguments as the customer creation call.
2355#[derive(Clone, Debug, serde::Serialize)]
2356pub struct UpdateCustomer {
2357    inner: UpdateCustomerBuilder,
2358    customer: stripe_shared::CustomerId,
2359}
2360impl UpdateCustomer {
2361    /// Construct a new `UpdateCustomer`.
2362    pub fn new(customer: impl Into<stripe_shared::CustomerId>) -> Self {
2363        Self { customer: customer.into(), inner: UpdateCustomerBuilder::new() }
2364    }
2365    /// The customer's address.
2366    pub fn address(mut self, address: impl Into<OptionalFieldsCustomerAddress>) -> Self {
2367        self.inner.address = Some(address.into());
2368        self
2369    }
2370    /// An integer amount in cents (or local equivalent) that represents the customer's current balance, which affect the customer's future invoices.
2371    /// A negative amount represents a credit that decreases the amount due on an invoice; a positive amount increases the amount due on an invoice.
2372    pub fn balance(mut self, balance: impl Into<i64>) -> Self {
2373        self.inner.balance = Some(balance.into());
2374        self
2375    }
2376    /// The customer's business name. This may be up to *150 characters*.
2377    pub fn business_name(mut self, business_name: impl Into<String>) -> Self {
2378        self.inner.business_name = Some(business_name.into());
2379        self
2380    }
2381    /// Balance information and default balance settings for this customer.
2382    pub fn cash_balance(mut self, cash_balance: impl Into<UpdateCustomerCashBalance>) -> Self {
2383        self.inner.cash_balance = Some(cash_balance.into());
2384        self
2385    }
2386    /// If you are using payment methods created via the PaymentMethods API, see the [invoice_settings.default_payment_method](https://stripe.com/docs/api/customers/update#update_customer-invoice_settings-default_payment_method) parameter.
2387    ///
2388    /// Provide the ID of a payment source already attached to this customer to make it this customer's default payment source.
2389    ///
2390    /// If you want to add a new payment source and make it the default, see the [source](https://stripe.com/docs/api/customers/update#update_customer-source) property.
2391    pub fn default_source(mut self, default_source: impl Into<String>) -> Self {
2392        self.inner.default_source = Some(default_source.into());
2393        self
2394    }
2395    /// An arbitrary string that you can attach to a customer object.
2396    /// It is displayed alongside the customer in the dashboard.
2397    pub fn description(mut self, description: impl Into<String>) -> Self {
2398        self.inner.description = Some(description.into());
2399        self
2400    }
2401    /// Customer's email address.
2402    /// It's displayed alongside the customer in your dashboard and can be useful for searching and tracking.
2403    /// This may be up to *512 characters*.
2404    pub fn email(mut self, email: impl Into<String>) -> Self {
2405        self.inner.email = Some(email.into());
2406        self
2407    }
2408    /// Specifies which fields in the response should be expanded.
2409    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
2410        self.inner.expand = Some(expand.into());
2411        self
2412    }
2413    /// The customer's full name. This may be up to *150 characters*.
2414    pub fn individual_name(mut self, individual_name: impl Into<String>) -> Self {
2415        self.inner.individual_name = Some(individual_name.into());
2416        self
2417    }
2418    /// The prefix for the customer used to generate unique invoice numbers.
2419    /// Must be 3–12 uppercase letters or numbers.
2420    pub fn invoice_prefix(mut self, invoice_prefix: impl Into<String>) -> Self {
2421        self.inner.invoice_prefix = Some(invoice_prefix.into());
2422        self
2423    }
2424    /// Default invoice settings for this customer.
2425    pub fn invoice_settings(
2426        mut self,
2427        invoice_settings: impl Into<UpdateCustomerInvoiceSettings>,
2428    ) -> Self {
2429        self.inner.invoice_settings = Some(invoice_settings.into());
2430        self
2431    }
2432    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
2433    /// This can be useful for storing additional information about the object in a structured format.
2434    /// Individual keys can be unset by posting an empty value to them.
2435    /// All keys can be unset by posting an empty value to `metadata`.
2436    pub fn metadata(
2437        mut self,
2438        metadata: impl Into<std::collections::HashMap<String, String>>,
2439    ) -> Self {
2440        self.inner.metadata = Some(metadata.into());
2441        self
2442    }
2443    /// The customer's full name or business name.
2444    pub fn name(mut self, name: impl Into<String>) -> Self {
2445        self.inner.name = Some(name.into());
2446        self
2447    }
2448    /// The sequence to be used on the customer's next invoice. Defaults to 1.
2449    pub fn next_invoice_sequence(mut self, next_invoice_sequence: impl Into<i64>) -> Self {
2450        self.inner.next_invoice_sequence = Some(next_invoice_sequence.into());
2451        self
2452    }
2453    /// The customer's phone number.
2454    pub fn phone(mut self, phone: impl Into<String>) -> Self {
2455        self.inner.phone = Some(phone.into());
2456        self
2457    }
2458    /// Customer's preferred languages, ordered by preference.
2459    pub fn preferred_locales(mut self, preferred_locales: impl Into<Vec<String>>) -> Self {
2460        self.inner.preferred_locales = Some(preferred_locales.into());
2461        self
2462    }
2463    /// The customer's shipping information. Appears on invoices emailed to this customer.
2464    pub fn shipping(mut self, shipping: impl Into<CustomerShipping>) -> Self {
2465        self.inner.shipping = Some(shipping.into());
2466        self
2467    }
2468    pub fn source(mut self, source: impl Into<String>) -> Self {
2469        self.inner.source = Some(source.into());
2470        self
2471    }
2472    /// Tax details about the customer.
2473    pub fn tax(mut self, tax: impl Into<UpdateCustomerTax>) -> Self {
2474        self.inner.tax = Some(tax.into());
2475        self
2476    }
2477    /// The customer's tax exemption. One of `none`, `exempt`, or `reverse`.
2478    pub fn tax_exempt(mut self, tax_exempt: impl Into<stripe_shared::CustomerTaxExempt>) -> Self {
2479        self.inner.tax_exempt = Some(tax_exempt.into());
2480        self
2481    }
2482    pub fn validate(mut self, validate: impl Into<bool>) -> Self {
2483        self.inner.validate = Some(validate.into());
2484        self
2485    }
2486}
2487impl UpdateCustomer {
2488    /// Send the request and return the deserialized response.
2489    pub async fn send<C: StripeClient>(
2490        &self,
2491        client: &C,
2492    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
2493        self.customize().send(client).await
2494    }
2495
2496    /// Send the request and return the deserialized response, blocking until completion.
2497    pub fn send_blocking<C: StripeBlockingClient>(
2498        &self,
2499        client: &C,
2500    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
2501        self.customize().send_blocking(client)
2502    }
2503}
2504
2505impl StripeRequest for UpdateCustomer {
2506    type Output = stripe_shared::Customer;
2507
2508    fn build(&self) -> RequestBuilder {
2509        let customer = &self.customer;
2510        RequestBuilder::new(StripeMethod::Post, format!("/customers/{customer}")).form(&self.inner)
2511    }
2512}
2513#[derive(Clone, Debug, serde::Serialize)]
2514struct CreateFundingInstructionsCustomerBuilder {
2515    bank_transfer: CreateFundingInstructionsCustomerBankTransfer,
2516    currency: stripe_types::Currency,
2517    #[serde(skip_serializing_if = "Option::is_none")]
2518    expand: Option<Vec<String>>,
2519    funding_type: CreateFundingInstructionsCustomerFundingType,
2520}
2521impl CreateFundingInstructionsCustomerBuilder {
2522    fn new(
2523        bank_transfer: impl Into<CreateFundingInstructionsCustomerBankTransfer>,
2524        currency: impl Into<stripe_types::Currency>,
2525        funding_type: impl Into<CreateFundingInstructionsCustomerFundingType>,
2526    ) -> Self {
2527        Self {
2528            bank_transfer: bank_transfer.into(),
2529            currency: currency.into(),
2530            expand: None,
2531            funding_type: funding_type.into(),
2532        }
2533    }
2534}
2535/// Additional parameters for `bank_transfer` funding types
2536#[derive(Clone, Debug, serde::Serialize)]
2537pub struct CreateFundingInstructionsCustomerBankTransfer {
2538    /// Configuration for eu_bank_transfer funding type.
2539    #[serde(skip_serializing_if = "Option::is_none")]
2540    pub eu_bank_transfer: Option<CreateFundingInstructionsCustomerBankTransferEuBankTransfer>,
2541    /// List of address types that should be returned in the financial_addresses response.
2542    /// If not specified, all valid types will be returned.
2543    ///
2544    /// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`.
2545    #[serde(skip_serializing_if = "Option::is_none")]
2546    pub requested_address_types:
2547        Option<Vec<CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes>>,
2548    /// The type of the `bank_transfer`
2549    #[serde(rename = "type")]
2550    pub type_: CreateFundingInstructionsCustomerBankTransferType,
2551}
2552impl CreateFundingInstructionsCustomerBankTransfer {
2553    pub fn new(type_: impl Into<CreateFundingInstructionsCustomerBankTransferType>) -> Self {
2554        Self { eu_bank_transfer: None, requested_address_types: None, type_: type_.into() }
2555    }
2556}
2557/// Configuration for eu_bank_transfer funding type.
2558#[derive(Clone, Debug, serde::Serialize)]
2559pub struct CreateFundingInstructionsCustomerBankTransferEuBankTransfer {
2560    /// The desired country code of the bank account information.
2561    /// Permitted values include: `BE`, `DE`, `ES`, `FR`, `IE`, or `NL`.
2562    pub country: String,
2563}
2564impl CreateFundingInstructionsCustomerBankTransferEuBankTransfer {
2565    pub fn new(country: impl Into<String>) -> Self {
2566        Self { country: country.into() }
2567    }
2568}
2569/// List of address types that should be returned in the financial_addresses response.
2570/// If not specified, all valid types will be returned.
2571///
2572/// Permitted values include: `sort_code`, `zengin`, `iban`, or `spei`.
2573#[derive(Clone, Eq, PartialEq)]
2574#[non_exhaustive]
2575pub enum CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes {
2576    Iban,
2577    SortCode,
2578    Spei,
2579    Zengin,
2580    /// An unrecognized value from Stripe. Should not be used as a request parameter.
2581    Unknown(String),
2582}
2583impl CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes {
2584    pub fn as_str(&self) -> &str {
2585        use CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes::*;
2586        match self {
2587            Iban => "iban",
2588            SortCode => "sort_code",
2589            Spei => "spei",
2590            Zengin => "zengin",
2591            Unknown(v) => v,
2592        }
2593    }
2594}
2595
2596impl std::str::FromStr for CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes {
2597    type Err = std::convert::Infallible;
2598    fn from_str(s: &str) -> Result<Self, Self::Err> {
2599        use CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes::*;
2600        match s {
2601            "iban" => Ok(Iban),
2602            "sort_code" => Ok(SortCode),
2603            "spei" => Ok(Spei),
2604            "zengin" => Ok(Zengin),
2605            v => {
2606                tracing::warn!(
2607                    "Unknown value '{}' for enum '{}'",
2608                    v,
2609                    "CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes"
2610                );
2611                Ok(Unknown(v.to_owned()))
2612            }
2613        }
2614    }
2615}
2616impl std::fmt::Display for CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes {
2617    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2618        f.write_str(self.as_str())
2619    }
2620}
2621
2622impl std::fmt::Debug for CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes {
2623    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2624        f.write_str(self.as_str())
2625    }
2626}
2627impl serde::Serialize for CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes {
2628    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2629    where
2630        S: serde::Serializer,
2631    {
2632        serializer.serialize_str(self.as_str())
2633    }
2634}
2635#[cfg(feature = "deserialize")]
2636impl<'de> serde::Deserialize<'de>
2637    for CreateFundingInstructionsCustomerBankTransferRequestedAddressTypes
2638{
2639    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2640        use std::str::FromStr;
2641        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
2642        Ok(Self::from_str(&s).expect("infallible"))
2643    }
2644}
2645/// The type of the `bank_transfer`
2646#[derive(Clone, Eq, PartialEq)]
2647#[non_exhaustive]
2648pub enum CreateFundingInstructionsCustomerBankTransferType {
2649    EuBankTransfer,
2650    GbBankTransfer,
2651    JpBankTransfer,
2652    MxBankTransfer,
2653    UsBankTransfer,
2654    /// An unrecognized value from Stripe. Should not be used as a request parameter.
2655    Unknown(String),
2656}
2657impl CreateFundingInstructionsCustomerBankTransferType {
2658    pub fn as_str(&self) -> &str {
2659        use CreateFundingInstructionsCustomerBankTransferType::*;
2660        match self {
2661            EuBankTransfer => "eu_bank_transfer",
2662            GbBankTransfer => "gb_bank_transfer",
2663            JpBankTransfer => "jp_bank_transfer",
2664            MxBankTransfer => "mx_bank_transfer",
2665            UsBankTransfer => "us_bank_transfer",
2666            Unknown(v) => v,
2667        }
2668    }
2669}
2670
2671impl std::str::FromStr for CreateFundingInstructionsCustomerBankTransferType {
2672    type Err = std::convert::Infallible;
2673    fn from_str(s: &str) -> Result<Self, Self::Err> {
2674        use CreateFundingInstructionsCustomerBankTransferType::*;
2675        match s {
2676            "eu_bank_transfer" => Ok(EuBankTransfer),
2677            "gb_bank_transfer" => Ok(GbBankTransfer),
2678            "jp_bank_transfer" => Ok(JpBankTransfer),
2679            "mx_bank_transfer" => Ok(MxBankTransfer),
2680            "us_bank_transfer" => Ok(UsBankTransfer),
2681            v => {
2682                tracing::warn!(
2683                    "Unknown value '{}' for enum '{}'",
2684                    v,
2685                    "CreateFundingInstructionsCustomerBankTransferType"
2686                );
2687                Ok(Unknown(v.to_owned()))
2688            }
2689        }
2690    }
2691}
2692impl std::fmt::Display for CreateFundingInstructionsCustomerBankTransferType {
2693    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2694        f.write_str(self.as_str())
2695    }
2696}
2697
2698impl std::fmt::Debug for CreateFundingInstructionsCustomerBankTransferType {
2699    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2700        f.write_str(self.as_str())
2701    }
2702}
2703impl serde::Serialize for CreateFundingInstructionsCustomerBankTransferType {
2704    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2705    where
2706        S: serde::Serializer,
2707    {
2708        serializer.serialize_str(self.as_str())
2709    }
2710}
2711#[cfg(feature = "deserialize")]
2712impl<'de> serde::Deserialize<'de> for CreateFundingInstructionsCustomerBankTransferType {
2713    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2714        use std::str::FromStr;
2715        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
2716        Ok(Self::from_str(&s).expect("infallible"))
2717    }
2718}
2719/// The `funding_type` to get the instructions for.
2720#[derive(Clone, Eq, PartialEq)]
2721#[non_exhaustive]
2722pub enum CreateFundingInstructionsCustomerFundingType {
2723    BankTransfer,
2724    /// An unrecognized value from Stripe. Should not be used as a request parameter.
2725    Unknown(String),
2726}
2727impl CreateFundingInstructionsCustomerFundingType {
2728    pub fn as_str(&self) -> &str {
2729        use CreateFundingInstructionsCustomerFundingType::*;
2730        match self {
2731            BankTransfer => "bank_transfer",
2732            Unknown(v) => v,
2733        }
2734    }
2735}
2736
2737impl std::str::FromStr for CreateFundingInstructionsCustomerFundingType {
2738    type Err = std::convert::Infallible;
2739    fn from_str(s: &str) -> Result<Self, Self::Err> {
2740        use CreateFundingInstructionsCustomerFundingType::*;
2741        match s {
2742            "bank_transfer" => Ok(BankTransfer),
2743            v => {
2744                tracing::warn!(
2745                    "Unknown value '{}' for enum '{}'",
2746                    v,
2747                    "CreateFundingInstructionsCustomerFundingType"
2748                );
2749                Ok(Unknown(v.to_owned()))
2750            }
2751        }
2752    }
2753}
2754impl std::fmt::Display for CreateFundingInstructionsCustomerFundingType {
2755    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2756        f.write_str(self.as_str())
2757    }
2758}
2759
2760impl std::fmt::Debug for CreateFundingInstructionsCustomerFundingType {
2761    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
2762        f.write_str(self.as_str())
2763    }
2764}
2765impl serde::Serialize for CreateFundingInstructionsCustomerFundingType {
2766    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
2767    where
2768        S: serde::Serializer,
2769    {
2770        serializer.serialize_str(self.as_str())
2771    }
2772}
2773#[cfg(feature = "deserialize")]
2774impl<'de> serde::Deserialize<'de> for CreateFundingInstructionsCustomerFundingType {
2775    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
2776        use std::str::FromStr;
2777        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
2778        Ok(Self::from_str(&s).expect("infallible"))
2779    }
2780}
2781/// Retrieve funding instructions for a customer cash balance.
2782/// If funding instructions do not yet exist for the customer, new.
2783/// funding instructions will be created.
2784/// If funding instructions have already been created for a given customer, the same.
2785/// funding instructions will be retrieved.
2786/// In other words, we will return the same funding instructions each time.
2787#[derive(Clone, Debug, serde::Serialize)]
2788pub struct CreateFundingInstructionsCustomer {
2789    inner: CreateFundingInstructionsCustomerBuilder,
2790    customer: stripe_shared::CustomerId,
2791}
2792impl CreateFundingInstructionsCustomer {
2793    /// Construct a new `CreateFundingInstructionsCustomer`.
2794    pub fn new(
2795        customer: impl Into<stripe_shared::CustomerId>,
2796        bank_transfer: impl Into<CreateFundingInstructionsCustomerBankTransfer>,
2797        currency: impl Into<stripe_types::Currency>,
2798        funding_type: impl Into<CreateFundingInstructionsCustomerFundingType>,
2799    ) -> Self {
2800        Self {
2801            customer: customer.into(),
2802            inner: CreateFundingInstructionsCustomerBuilder::new(
2803                bank_transfer.into(),
2804                currency.into(),
2805                funding_type.into(),
2806            ),
2807        }
2808    }
2809    /// Specifies which fields in the response should be expanded.
2810    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
2811        self.inner.expand = Some(expand.into());
2812        self
2813    }
2814}
2815impl CreateFundingInstructionsCustomer {
2816    /// Send the request and return the deserialized response.
2817    pub async fn send<C: StripeClient>(
2818        &self,
2819        client: &C,
2820    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
2821        self.customize().send(client).await
2822    }
2823
2824    /// Send the request and return the deserialized response, blocking until completion.
2825    pub fn send_blocking<C: StripeBlockingClient>(
2826        &self,
2827        client: &C,
2828    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
2829        self.customize().send_blocking(client)
2830    }
2831}
2832
2833impl StripeRequest for CreateFundingInstructionsCustomer {
2834    type Output = stripe_shared::FundingInstructions;
2835
2836    fn build(&self) -> RequestBuilder {
2837        let customer = &self.customer;
2838        RequestBuilder::new(
2839            StripeMethod::Post,
2840            format!("/customers/{customer}/funding_instructions"),
2841        )
2842        .form(&self.inner)
2843    }
2844}
2845#[derive(Clone, Debug, serde::Serialize)]
2846struct FundCashBalanceCustomerBuilder {
2847    amount: i64,
2848    currency: stripe_types::Currency,
2849    #[serde(skip_serializing_if = "Option::is_none")]
2850    expand: Option<Vec<String>>,
2851    #[serde(skip_serializing_if = "Option::is_none")]
2852    reference: Option<String>,
2853}
2854impl FundCashBalanceCustomerBuilder {
2855    fn new(amount: impl Into<i64>, currency: impl Into<stripe_types::Currency>) -> Self {
2856        Self { amount: amount.into(), currency: currency.into(), expand: None, reference: None }
2857    }
2858}
2859/// Create an incoming testmode bank transfer
2860#[derive(Clone, Debug, serde::Serialize)]
2861pub struct FundCashBalanceCustomer {
2862    inner: FundCashBalanceCustomerBuilder,
2863    customer: String,
2864}
2865impl FundCashBalanceCustomer {
2866    /// Construct a new `FundCashBalanceCustomer`.
2867    pub fn new(
2868        customer: impl Into<String>,
2869        amount: impl Into<i64>,
2870        currency: impl Into<stripe_types::Currency>,
2871    ) -> Self {
2872        Self {
2873            customer: customer.into(),
2874            inner: FundCashBalanceCustomerBuilder::new(amount.into(), currency.into()),
2875        }
2876    }
2877    /// Specifies which fields in the response should be expanded.
2878    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
2879        self.inner.expand = Some(expand.into());
2880        self
2881    }
2882    /// A description of the test funding.
2883    /// This simulates free-text references supplied by customers when making bank transfers to their cash balance.
2884    /// You can use this to test how Stripe's [reconciliation algorithm](https://stripe.com/docs/payments/customer-balance/reconciliation) applies to different user inputs.
2885    pub fn reference(mut self, reference: impl Into<String>) -> Self {
2886        self.inner.reference = Some(reference.into());
2887        self
2888    }
2889}
2890impl FundCashBalanceCustomer {
2891    /// Send the request and return the deserialized response.
2892    pub async fn send<C: StripeClient>(
2893        &self,
2894        client: &C,
2895    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
2896        self.customize().send(client).await
2897    }
2898
2899    /// Send the request and return the deserialized response, blocking until completion.
2900    pub fn send_blocking<C: StripeBlockingClient>(
2901        &self,
2902        client: &C,
2903    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
2904        self.customize().send_blocking(client)
2905    }
2906}
2907
2908impl StripeRequest for FundCashBalanceCustomer {
2909    type Output = stripe_shared::CustomerCashBalanceTransaction;
2910
2911    fn build(&self) -> RequestBuilder {
2912        let customer = &self.customer;
2913        RequestBuilder::new(
2914            StripeMethod::Post,
2915            format!("/test_helpers/customers/{customer}/fund_cash_balance"),
2916        )
2917        .form(&self.inner)
2918    }
2919}
2920
2921#[derive(Clone, Debug, serde::Serialize)]
2922pub struct OptionalFieldsCustomerAddress {
2923    /// City, district, suburb, town, or village.
2924    #[serde(skip_serializing_if = "Option::is_none")]
2925    pub city: Option<String>,
2926    /// A freeform text field for the country.
2927    /// However, in order to activate some tax features, the format should be a two-letter country code ([ISO 3166-1 alpha-2](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)).
2928    #[serde(skip_serializing_if = "Option::is_none")]
2929    pub country: Option<String>,
2930    /// Address line 1, such as the street, PO Box, or company name.
2931    #[serde(skip_serializing_if = "Option::is_none")]
2932    pub line1: Option<String>,
2933    /// Address line 2, such as the apartment, suite, unit, or building.
2934    #[serde(skip_serializing_if = "Option::is_none")]
2935    pub line2: Option<String>,
2936    /// ZIP or postal code.
2937    #[serde(skip_serializing_if = "Option::is_none")]
2938    pub postal_code: Option<String>,
2939    /// State, county, province, or region.
2940    #[serde(skip_serializing_if = "Option::is_none")]
2941    pub state: Option<String>,
2942}
2943impl OptionalFieldsCustomerAddress {
2944    pub fn new() -> Self {
2945        Self { city: None, country: None, line1: None, line2: None, postal_code: None, state: None }
2946    }
2947}
2948impl Default for OptionalFieldsCustomerAddress {
2949    fn default() -> Self {
2950        Self::new()
2951    }
2952}
2953#[derive(Clone, Debug, serde::Serialize)]
2954pub struct CustomFieldParams {
2955    /// The name of the custom field. This may be up to 40 characters.
2956    pub name: String,
2957    /// The value of the custom field. This may be up to 140 characters.
2958    pub value: String,
2959}
2960impl CustomFieldParams {
2961    pub fn new(name: impl Into<String>, value: impl Into<String>) -> Self {
2962        Self { name: name.into(), value: value.into() }
2963    }
2964}
2965#[derive(Clone, Debug, serde::Serialize)]
2966pub struct CustomerShipping {
2967    /// Customer shipping address.
2968    pub address: OptionalFieldsCustomerAddress,
2969    /// Customer name.
2970    pub name: String,
2971    /// Customer phone (including extension).
2972    #[serde(skip_serializing_if = "Option::is_none")]
2973    pub phone: Option<String>,
2974}
2975impl CustomerShipping {
2976    pub fn new(address: impl Into<OptionalFieldsCustomerAddress>, name: impl Into<String>) -> Self {
2977        Self { address: address.into(), name: name.into(), phone: None }
2978    }
2979}