stripe_shared/
person.rs

1/// This is an object representing a person associated with a Stripe account.
2///
3/// A platform can only access a subset of data in a person for an account where [account.controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`, which includes Standard and Express accounts, after creating an Account Link or Account Session to start Connect onboarding.
4///
5/// See the [Standard onboarding](/connect/standard-accounts) or [Express onboarding](/connect/express-accounts) documentation for information about prefilling information and account onboarding steps.
6/// Learn more about [handling identity verification with the API](/connect/handling-api-verification#person-information).
7///
8/// For more details see <<https://stripe.com/docs/api/persons/object>>.
9#[derive(Clone, Debug)]
10#[cfg_attr(feature = "deserialize", derive(serde::Deserialize))]
11pub struct Person {
12    /// The account the person is associated with.
13    pub account: Option<String>,
14    pub additional_tos_acceptances: Option<stripe_shared::PersonAdditionalTosAcceptances>,
15    pub address: Option<stripe_shared::Address>,
16    /// The Kana variation of the person's address (Japan only).
17    pub address_kana: Option<stripe_shared::LegalEntityJapanAddress>,
18    /// The Kanji variation of the person's address (Japan only).
19    pub address_kanji: Option<stripe_shared::LegalEntityJapanAddress>,
20    /// Time at which the object was created. Measured in seconds since the Unix epoch.
21    pub created: stripe_types::Timestamp,
22    pub dob: Option<stripe_shared::LegalEntityDob>,
23    /// The person's email address.
24    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
25    pub email: Option<String>,
26    /// The person's first name.
27    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
28    pub first_name: Option<String>,
29    /// The Kana variation of the person's first name (Japan only).
30    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
31    pub first_name_kana: Option<String>,
32    /// The Kanji variation of the person's first name (Japan only).
33    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
34    pub first_name_kanji: Option<String>,
35    /// A list of alternate names or aliases that the person is known by.
36    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
37    pub full_name_aliases: Option<Vec<String>>,
38    /// Information about the [upcoming new requirements for this person](https://stripe.com/docs/connect/custom-accounts/future-requirements), including what information needs to be collected, and by when.
39    pub future_requirements: Option<stripe_shared::PersonFutureRequirements>,
40    /// The person's gender.
41    pub gender: Option<String>,
42    /// Unique identifier for the object.
43    pub id: stripe_shared::PersonId,
44    /// Whether the person's `id_number` was provided.
45    /// True if either the full ID number was provided or if only the required part of the ID number was provided (ex.
46    /// last four of an individual's SSN for the US indicated by `ssn_last_4_provided`).
47    pub id_number_provided: Option<bool>,
48    /// Whether the person's `id_number_secondary` was provided.
49    pub id_number_secondary_provided: Option<bool>,
50    /// The person's last name.
51    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
52    pub last_name: Option<String>,
53    /// The Kana variation of the person's last name (Japan only).
54    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
55    pub last_name_kana: Option<String>,
56    /// The Kanji variation of the person's last name (Japan only).
57    /// Also available for accounts where [controller.requirement_collection](/api/accounts/object#account_object-controller-requirement_collection) is `stripe`.
58    pub last_name_kanji: Option<String>,
59    /// The person's maiden name.
60    pub maiden_name: Option<String>,
61    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
62    /// This can be useful for storing additional information about the object in a structured format.
63    pub metadata: Option<std::collections::HashMap<String, String>>,
64    /// The country where the person is a national.
65    pub nationality: Option<String>,
66    /// The person's phone number.
67    pub phone: Option<String>,
68    /// Indicates if the person or any of their representatives, family members, or other closely related persons, declares that they hold or have held an important public job or function, in any jurisdiction.
69    pub political_exposure: Option<stripe_shared::PersonPoliticalExposure>,
70    pub registered_address: Option<stripe_shared::Address>,
71    pub relationship: Option<stripe_shared::PersonRelationship>,
72    /// Information about the requirements for this person, including what information needs to be collected, and by when.
73    pub requirements: Option<stripe_shared::PersonRequirements>,
74    /// Whether the last four digits of the person's Social Security number have been provided (U.S. only).
75    pub ssn_last_4_provided: Option<bool>,
76    /// Demographic data related to the person.
77    pub us_cfpb_data: Option<stripe_shared::PersonUsCfpbData>,
78    pub verification: Option<stripe_shared::LegalEntityPersonVerification>,
79}
80#[doc(hidden)]
81pub struct PersonBuilder {
82    account: Option<Option<String>>,
83    additional_tos_acceptances: Option<Option<stripe_shared::PersonAdditionalTosAcceptances>>,
84    address: Option<Option<stripe_shared::Address>>,
85    address_kana: Option<Option<stripe_shared::LegalEntityJapanAddress>>,
86    address_kanji: Option<Option<stripe_shared::LegalEntityJapanAddress>>,
87    created: Option<stripe_types::Timestamp>,
88    dob: Option<Option<stripe_shared::LegalEntityDob>>,
89    email: Option<Option<String>>,
90    first_name: Option<Option<String>>,
91    first_name_kana: Option<Option<String>>,
92    first_name_kanji: Option<Option<String>>,
93    full_name_aliases: Option<Option<Vec<String>>>,
94    future_requirements: Option<Option<stripe_shared::PersonFutureRequirements>>,
95    gender: Option<Option<String>>,
96    id: Option<stripe_shared::PersonId>,
97    id_number_provided: Option<Option<bool>>,
98    id_number_secondary_provided: Option<Option<bool>>,
99    last_name: Option<Option<String>>,
100    last_name_kana: Option<Option<String>>,
101    last_name_kanji: Option<Option<String>>,
102    maiden_name: Option<Option<String>>,
103    metadata: Option<Option<std::collections::HashMap<String, String>>>,
104    nationality: Option<Option<String>>,
105    phone: Option<Option<String>>,
106    political_exposure: Option<Option<stripe_shared::PersonPoliticalExposure>>,
107    registered_address: Option<Option<stripe_shared::Address>>,
108    relationship: Option<Option<stripe_shared::PersonRelationship>>,
109    requirements: Option<Option<stripe_shared::PersonRequirements>>,
110    ssn_last_4_provided: Option<Option<bool>>,
111    us_cfpb_data: Option<Option<stripe_shared::PersonUsCfpbData>>,
112    verification: Option<Option<stripe_shared::LegalEntityPersonVerification>>,
113}
114
115#[allow(
116    unused_variables,
117    irrefutable_let_patterns,
118    clippy::let_unit_value,
119    clippy::match_single_binding,
120    clippy::single_match
121)]
122const _: () = {
123    use miniserde::de::{Map, Visitor};
124    use miniserde::json::Value;
125    use miniserde::{Deserialize, Result, make_place};
126    use stripe_types::miniserde_helpers::FromValueOpt;
127    use stripe_types::{MapBuilder, ObjectDeser};
128
129    make_place!(Place);
130
131    impl Deserialize for Person {
132        fn begin(out: &mut Option<Self>) -> &mut dyn Visitor {
133            Place::new(out)
134        }
135    }
136
137    struct Builder<'a> {
138        out: &'a mut Option<Person>,
139        builder: PersonBuilder,
140    }
141
142    impl Visitor for Place<Person> {
143        fn map(&mut self) -> Result<Box<dyn Map + '_>> {
144            Ok(Box::new(Builder { out: &mut self.out, builder: PersonBuilder::deser_default() }))
145        }
146    }
147
148    impl MapBuilder for PersonBuilder {
149        type Out = Person;
150        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
151            Ok(match k {
152                "account" => Deserialize::begin(&mut self.account),
153                "additional_tos_acceptances" => {
154                    Deserialize::begin(&mut self.additional_tos_acceptances)
155                }
156                "address" => Deserialize::begin(&mut self.address),
157                "address_kana" => Deserialize::begin(&mut self.address_kana),
158                "address_kanji" => Deserialize::begin(&mut self.address_kanji),
159                "created" => Deserialize::begin(&mut self.created),
160                "dob" => Deserialize::begin(&mut self.dob),
161                "email" => Deserialize::begin(&mut self.email),
162                "first_name" => Deserialize::begin(&mut self.first_name),
163                "first_name_kana" => Deserialize::begin(&mut self.first_name_kana),
164                "first_name_kanji" => Deserialize::begin(&mut self.first_name_kanji),
165                "full_name_aliases" => Deserialize::begin(&mut self.full_name_aliases),
166                "future_requirements" => Deserialize::begin(&mut self.future_requirements),
167                "gender" => Deserialize::begin(&mut self.gender),
168                "id" => Deserialize::begin(&mut self.id),
169                "id_number_provided" => Deserialize::begin(&mut self.id_number_provided),
170                "id_number_secondary_provided" => {
171                    Deserialize::begin(&mut self.id_number_secondary_provided)
172                }
173                "last_name" => Deserialize::begin(&mut self.last_name),
174                "last_name_kana" => Deserialize::begin(&mut self.last_name_kana),
175                "last_name_kanji" => Deserialize::begin(&mut self.last_name_kanji),
176                "maiden_name" => Deserialize::begin(&mut self.maiden_name),
177                "metadata" => Deserialize::begin(&mut self.metadata),
178                "nationality" => Deserialize::begin(&mut self.nationality),
179                "phone" => Deserialize::begin(&mut self.phone),
180                "political_exposure" => Deserialize::begin(&mut self.political_exposure),
181                "registered_address" => Deserialize::begin(&mut self.registered_address),
182                "relationship" => Deserialize::begin(&mut self.relationship),
183                "requirements" => Deserialize::begin(&mut self.requirements),
184                "ssn_last_4_provided" => Deserialize::begin(&mut self.ssn_last_4_provided),
185                "us_cfpb_data" => Deserialize::begin(&mut self.us_cfpb_data),
186                "verification" => Deserialize::begin(&mut self.verification),
187                _ => <dyn Visitor>::ignore(),
188            })
189        }
190
191        fn deser_default() -> Self {
192            Self {
193                account: Deserialize::default(),
194                additional_tos_acceptances: Deserialize::default(),
195                address: Deserialize::default(),
196                address_kana: Deserialize::default(),
197                address_kanji: Deserialize::default(),
198                created: Deserialize::default(),
199                dob: Deserialize::default(),
200                email: Deserialize::default(),
201                first_name: Deserialize::default(),
202                first_name_kana: Deserialize::default(),
203                first_name_kanji: Deserialize::default(),
204                full_name_aliases: Deserialize::default(),
205                future_requirements: Deserialize::default(),
206                gender: Deserialize::default(),
207                id: Deserialize::default(),
208                id_number_provided: Deserialize::default(),
209                id_number_secondary_provided: Deserialize::default(),
210                last_name: Deserialize::default(),
211                last_name_kana: Deserialize::default(),
212                last_name_kanji: Deserialize::default(),
213                maiden_name: Deserialize::default(),
214                metadata: Deserialize::default(),
215                nationality: Deserialize::default(),
216                phone: Deserialize::default(),
217                political_exposure: Deserialize::default(),
218                registered_address: Deserialize::default(),
219                relationship: Deserialize::default(),
220                requirements: Deserialize::default(),
221                ssn_last_4_provided: Deserialize::default(),
222                us_cfpb_data: Deserialize::default(),
223                verification: Deserialize::default(),
224            }
225        }
226
227        fn take_out(&mut self) -> Option<Self::Out> {
228            let (
229                Some(account),
230                Some(additional_tos_acceptances),
231                Some(address),
232                Some(address_kana),
233                Some(address_kanji),
234                Some(created),
235                Some(dob),
236                Some(email),
237                Some(first_name),
238                Some(first_name_kana),
239                Some(first_name_kanji),
240                Some(full_name_aliases),
241                Some(future_requirements),
242                Some(gender),
243                Some(id),
244                Some(id_number_provided),
245                Some(id_number_secondary_provided),
246                Some(last_name),
247                Some(last_name_kana),
248                Some(last_name_kanji),
249                Some(maiden_name),
250                Some(metadata),
251                Some(nationality),
252                Some(phone),
253                Some(political_exposure),
254                Some(registered_address),
255                Some(relationship),
256                Some(requirements),
257                Some(ssn_last_4_provided),
258                Some(us_cfpb_data),
259                Some(verification),
260            ) = (
261                self.account.take(),
262                self.additional_tos_acceptances.take(),
263                self.address.take(),
264                self.address_kana.take(),
265                self.address_kanji.take(),
266                self.created,
267                self.dob,
268                self.email.take(),
269                self.first_name.take(),
270                self.first_name_kana.take(),
271                self.first_name_kanji.take(),
272                self.full_name_aliases.take(),
273                self.future_requirements.take(),
274                self.gender.take(),
275                self.id.take(),
276                self.id_number_provided,
277                self.id_number_secondary_provided,
278                self.last_name.take(),
279                self.last_name_kana.take(),
280                self.last_name_kanji.take(),
281                self.maiden_name.take(),
282                self.metadata.take(),
283                self.nationality.take(),
284                self.phone.take(),
285                self.political_exposure.take(),
286                self.registered_address.take(),
287                self.relationship.take(),
288                self.requirements.take(),
289                self.ssn_last_4_provided,
290                self.us_cfpb_data.take(),
291                self.verification.take(),
292            )
293            else {
294                return None;
295            };
296            Some(Self::Out {
297                account,
298                additional_tos_acceptances,
299                address,
300                address_kana,
301                address_kanji,
302                created,
303                dob,
304                email,
305                first_name,
306                first_name_kana,
307                first_name_kanji,
308                full_name_aliases,
309                future_requirements,
310                gender,
311                id,
312                id_number_provided,
313                id_number_secondary_provided,
314                last_name,
315                last_name_kana,
316                last_name_kanji,
317                maiden_name,
318                metadata,
319                nationality,
320                phone,
321                political_exposure,
322                registered_address,
323                relationship,
324                requirements,
325                ssn_last_4_provided,
326                us_cfpb_data,
327                verification,
328            })
329        }
330    }
331
332    impl Map for Builder<'_> {
333        fn key(&mut self, k: &str) -> Result<&mut dyn Visitor> {
334            self.builder.key(k)
335        }
336
337        fn finish(&mut self) -> Result<()> {
338            *self.out = self.builder.take_out();
339            Ok(())
340        }
341    }
342
343    impl ObjectDeser for Person {
344        type Builder = PersonBuilder;
345    }
346
347    impl FromValueOpt for Person {
348        fn from_value(v: Value) -> Option<Self> {
349            let Value::Object(obj) = v else {
350                return None;
351            };
352            let mut b = PersonBuilder::deser_default();
353            for (k, v) in obj {
354                match k.as_str() {
355                    "account" => b.account = FromValueOpt::from_value(v),
356                    "additional_tos_acceptances" => {
357                        b.additional_tos_acceptances = FromValueOpt::from_value(v)
358                    }
359                    "address" => b.address = FromValueOpt::from_value(v),
360                    "address_kana" => b.address_kana = FromValueOpt::from_value(v),
361                    "address_kanji" => b.address_kanji = FromValueOpt::from_value(v),
362                    "created" => b.created = FromValueOpt::from_value(v),
363                    "dob" => b.dob = FromValueOpt::from_value(v),
364                    "email" => b.email = FromValueOpt::from_value(v),
365                    "first_name" => b.first_name = FromValueOpt::from_value(v),
366                    "first_name_kana" => b.first_name_kana = FromValueOpt::from_value(v),
367                    "first_name_kanji" => b.first_name_kanji = FromValueOpt::from_value(v),
368                    "full_name_aliases" => b.full_name_aliases = FromValueOpt::from_value(v),
369                    "future_requirements" => b.future_requirements = FromValueOpt::from_value(v),
370                    "gender" => b.gender = FromValueOpt::from_value(v),
371                    "id" => b.id = FromValueOpt::from_value(v),
372                    "id_number_provided" => b.id_number_provided = FromValueOpt::from_value(v),
373                    "id_number_secondary_provided" => {
374                        b.id_number_secondary_provided = FromValueOpt::from_value(v)
375                    }
376                    "last_name" => b.last_name = FromValueOpt::from_value(v),
377                    "last_name_kana" => b.last_name_kana = FromValueOpt::from_value(v),
378                    "last_name_kanji" => b.last_name_kanji = FromValueOpt::from_value(v),
379                    "maiden_name" => b.maiden_name = FromValueOpt::from_value(v),
380                    "metadata" => b.metadata = FromValueOpt::from_value(v),
381                    "nationality" => b.nationality = FromValueOpt::from_value(v),
382                    "phone" => b.phone = FromValueOpt::from_value(v),
383                    "political_exposure" => b.political_exposure = FromValueOpt::from_value(v),
384                    "registered_address" => b.registered_address = FromValueOpt::from_value(v),
385                    "relationship" => b.relationship = FromValueOpt::from_value(v),
386                    "requirements" => b.requirements = FromValueOpt::from_value(v),
387                    "ssn_last_4_provided" => b.ssn_last_4_provided = FromValueOpt::from_value(v),
388                    "us_cfpb_data" => b.us_cfpb_data = FromValueOpt::from_value(v),
389                    "verification" => b.verification = FromValueOpt::from_value(v),
390                    _ => {}
391                }
392            }
393            b.take_out()
394        }
395    }
396};
397#[cfg(feature = "serialize")]
398impl serde::Serialize for Person {
399    fn serialize<S: serde::Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
400        use serde::ser::SerializeStruct;
401        let mut s = s.serialize_struct("Person", 32)?;
402        s.serialize_field("account", &self.account)?;
403        s.serialize_field("additional_tos_acceptances", &self.additional_tos_acceptances)?;
404        s.serialize_field("address", &self.address)?;
405        s.serialize_field("address_kana", &self.address_kana)?;
406        s.serialize_field("address_kanji", &self.address_kanji)?;
407        s.serialize_field("created", &self.created)?;
408        s.serialize_field("dob", &self.dob)?;
409        s.serialize_field("email", &self.email)?;
410        s.serialize_field("first_name", &self.first_name)?;
411        s.serialize_field("first_name_kana", &self.first_name_kana)?;
412        s.serialize_field("first_name_kanji", &self.first_name_kanji)?;
413        s.serialize_field("full_name_aliases", &self.full_name_aliases)?;
414        s.serialize_field("future_requirements", &self.future_requirements)?;
415        s.serialize_field("gender", &self.gender)?;
416        s.serialize_field("id", &self.id)?;
417        s.serialize_field("id_number_provided", &self.id_number_provided)?;
418        s.serialize_field("id_number_secondary_provided", &self.id_number_secondary_provided)?;
419        s.serialize_field("last_name", &self.last_name)?;
420        s.serialize_field("last_name_kana", &self.last_name_kana)?;
421        s.serialize_field("last_name_kanji", &self.last_name_kanji)?;
422        s.serialize_field("maiden_name", &self.maiden_name)?;
423        s.serialize_field("metadata", &self.metadata)?;
424        s.serialize_field("nationality", &self.nationality)?;
425        s.serialize_field("phone", &self.phone)?;
426        s.serialize_field("political_exposure", &self.political_exposure)?;
427        s.serialize_field("registered_address", &self.registered_address)?;
428        s.serialize_field("relationship", &self.relationship)?;
429        s.serialize_field("requirements", &self.requirements)?;
430        s.serialize_field("ssn_last_4_provided", &self.ssn_last_4_provided)?;
431        s.serialize_field("us_cfpb_data", &self.us_cfpb_data)?;
432        s.serialize_field("verification", &self.verification)?;
433
434        s.serialize_field("object", "person")?;
435        s.end()
436    }
437}
438impl stripe_types::Object for Person {
439    type Id = stripe_shared::PersonId;
440    fn id(&self) -> &Self::Id {
441        &self.id
442    }
443
444    fn into_id(self) -> Self::Id {
445        self.id
446    }
447}
448stripe_types::def_id!(PersonId);
449#[derive(Clone, Eq, PartialEq)]
450#[non_exhaustive]
451pub enum PersonPoliticalExposure {
452    Existing,
453    None,
454    /// An unrecognized value from Stripe. Should not be used as a request parameter.
455    Unknown(String),
456}
457impl PersonPoliticalExposure {
458    pub fn as_str(&self) -> &str {
459        use PersonPoliticalExposure::*;
460        match self {
461            Existing => "existing",
462            None => "none",
463            Unknown(v) => v,
464        }
465    }
466}
467
468impl std::str::FromStr for PersonPoliticalExposure {
469    type Err = std::convert::Infallible;
470    fn from_str(s: &str) -> Result<Self, Self::Err> {
471        use PersonPoliticalExposure::*;
472        match s {
473            "existing" => Ok(Existing),
474            "none" => Ok(None),
475            v => {
476                tracing::warn!("Unknown value '{}' for enum '{}'", v, "PersonPoliticalExposure");
477                Ok(Unknown(v.to_owned()))
478            }
479        }
480    }
481}
482impl std::fmt::Display for PersonPoliticalExposure {
483    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
484        f.write_str(self.as_str())
485    }
486}
487
488impl std::fmt::Debug for PersonPoliticalExposure {
489    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
490        f.write_str(self.as_str())
491    }
492}
493impl serde::Serialize for PersonPoliticalExposure {
494    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
495    where
496        S: serde::Serializer,
497    {
498        serializer.serialize_str(self.as_str())
499    }
500}
501impl miniserde::Deserialize for PersonPoliticalExposure {
502    fn begin(out: &mut Option<Self>) -> &mut dyn miniserde::de::Visitor {
503        crate::Place::new(out)
504    }
505}
506
507impl miniserde::de::Visitor for crate::Place<PersonPoliticalExposure> {
508    fn string(&mut self, s: &str) -> miniserde::Result<()> {
509        use std::str::FromStr;
510        self.out = Some(PersonPoliticalExposure::from_str(s).expect("infallible"));
511        Ok(())
512    }
513}
514
515stripe_types::impl_from_val_with_from_str!(PersonPoliticalExposure);
516#[cfg(feature = "deserialize")]
517impl<'de> serde::Deserialize<'de> for PersonPoliticalExposure {
518    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
519        use std::str::FromStr;
520        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
521        Ok(Self::from_str(&s).expect("infallible"))
522    }
523}