stripe_misc/identity_verification_session/
requests.rs

1use stripe_client_core::{
2    RequestBuilder, StripeBlockingClient, StripeClient, StripeMethod, StripeRequest,
3};
4
5#[derive(Clone, Debug, serde::Serialize)]
6struct ListIdentityVerificationSessionBuilder {
7    #[serde(skip_serializing_if = "Option::is_none")]
8    client_reference_id: Option<String>,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    created: Option<stripe_types::RangeQueryTs>,
11    #[serde(skip_serializing_if = "Option::is_none")]
12    ending_before: Option<String>,
13    #[serde(skip_serializing_if = "Option::is_none")]
14    expand: Option<Vec<String>>,
15    #[serde(skip_serializing_if = "Option::is_none")]
16    limit: Option<i64>,
17    #[serde(skip_serializing_if = "Option::is_none")]
18    related_customer: Option<String>,
19    #[serde(skip_serializing_if = "Option::is_none")]
20    starting_after: Option<String>,
21    #[serde(skip_serializing_if = "Option::is_none")]
22    status: Option<stripe_misc::IdentityVerificationSessionStatus>,
23}
24impl ListIdentityVerificationSessionBuilder {
25    fn new() -> Self {
26        Self {
27            client_reference_id: None,
28            created: None,
29            ending_before: None,
30            expand: None,
31            limit: None,
32            related_customer: None,
33            starting_after: None,
34            status: None,
35        }
36    }
37}
38/// Returns a list of VerificationSessions
39#[derive(Clone, Debug, serde::Serialize)]
40pub struct ListIdentityVerificationSession {
41    inner: ListIdentityVerificationSessionBuilder,
42}
43impl ListIdentityVerificationSession {
44    /// Construct a new `ListIdentityVerificationSession`.
45    pub fn new() -> Self {
46        Self { inner: ListIdentityVerificationSessionBuilder::new() }
47    }
48    /// A string to reference this user.
49    /// This can be a customer ID, a session ID, or similar, and can be used to reconcile this verification with your internal systems.
50    pub fn client_reference_id(mut self, client_reference_id: impl Into<String>) -> Self {
51        self.inner.client_reference_id = Some(client_reference_id.into());
52        self
53    }
54    /// Only return VerificationSessions that were created during the given date interval.
55    pub fn created(mut self, created: impl Into<stripe_types::RangeQueryTs>) -> Self {
56        self.inner.created = Some(created.into());
57        self
58    }
59    /// A cursor for use in pagination.
60    /// `ending_before` is an object ID that defines your place in the list.
61    /// 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.
62    pub fn ending_before(mut self, ending_before: impl Into<String>) -> Self {
63        self.inner.ending_before = Some(ending_before.into());
64        self
65    }
66    /// Specifies which fields in the response should be expanded.
67    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
68        self.inner.expand = Some(expand.into());
69        self
70    }
71    /// A limit on the number of objects to be returned.
72    /// Limit can range between 1 and 100, and the default is 10.
73    pub fn limit(mut self, limit: impl Into<i64>) -> Self {
74        self.inner.limit = Some(limit.into());
75        self
76    }
77    pub fn related_customer(mut self, related_customer: impl Into<String>) -> Self {
78        self.inner.related_customer = Some(related_customer.into());
79        self
80    }
81    /// A cursor for use in pagination.
82    /// `starting_after` is an object ID that defines your place in the list.
83    /// 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.
84    pub fn starting_after(mut self, starting_after: impl Into<String>) -> Self {
85        self.inner.starting_after = Some(starting_after.into());
86        self
87    }
88    /// Only return VerificationSessions with this status.
89    /// [Learn more about the lifecycle of sessions](https://stripe.com/docs/identity/how-sessions-work).
90    pub fn status(
91        mut self,
92        status: impl Into<stripe_misc::IdentityVerificationSessionStatus>,
93    ) -> Self {
94        self.inner.status = Some(status.into());
95        self
96    }
97}
98impl Default for ListIdentityVerificationSession {
99    fn default() -> Self {
100        Self::new()
101    }
102}
103impl ListIdentityVerificationSession {
104    /// Send the request and return the deserialized response.
105    pub async fn send<C: StripeClient>(
106        &self,
107        client: &C,
108    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
109        self.customize().send(client).await
110    }
111
112    /// Send the request and return the deserialized response, blocking until completion.
113    pub fn send_blocking<C: StripeBlockingClient>(
114        &self,
115        client: &C,
116    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
117        self.customize().send_blocking(client)
118    }
119
120    pub fn paginate(
121        &self,
122    ) -> stripe_client_core::ListPaginator<
123        stripe_types::List<stripe_misc::IdentityVerificationSession>,
124    > {
125        stripe_client_core::ListPaginator::new_list("/identity/verification_sessions", &self.inner)
126    }
127}
128
129impl StripeRequest for ListIdentityVerificationSession {
130    type Output = stripe_types::List<stripe_misc::IdentityVerificationSession>;
131
132    fn build(&self) -> RequestBuilder {
133        RequestBuilder::new(StripeMethod::Get, "/identity/verification_sessions").query(&self.inner)
134    }
135}
136#[derive(Clone, Debug, serde::Serialize)]
137struct RetrieveIdentityVerificationSessionBuilder {
138    #[serde(skip_serializing_if = "Option::is_none")]
139    expand: Option<Vec<String>>,
140}
141impl RetrieveIdentityVerificationSessionBuilder {
142    fn new() -> Self {
143        Self { expand: None }
144    }
145}
146/// Retrieves the details of a VerificationSession that was previously created.
147///
148/// When the session status is `requires_input`, you can use this method to retrieve a valid
149/// `client_secret` or `url` to allow re-submission.
150#[derive(Clone, Debug, serde::Serialize)]
151pub struct RetrieveIdentityVerificationSession {
152    inner: RetrieveIdentityVerificationSessionBuilder,
153    session: stripe_misc::IdentityVerificationSessionId,
154}
155impl RetrieveIdentityVerificationSession {
156    /// Construct a new `RetrieveIdentityVerificationSession`.
157    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
158        Self { session: session.into(), inner: RetrieveIdentityVerificationSessionBuilder::new() }
159    }
160    /// Specifies which fields in the response should be expanded.
161    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
162        self.inner.expand = Some(expand.into());
163        self
164    }
165}
166impl RetrieveIdentityVerificationSession {
167    /// Send the request and return the deserialized response.
168    pub async fn send<C: StripeClient>(
169        &self,
170        client: &C,
171    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
172        self.customize().send(client).await
173    }
174
175    /// Send the request and return the deserialized response, blocking until completion.
176    pub fn send_blocking<C: StripeBlockingClient>(
177        &self,
178        client: &C,
179    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
180        self.customize().send_blocking(client)
181    }
182}
183
184impl StripeRequest for RetrieveIdentityVerificationSession {
185    type Output = stripe_misc::IdentityVerificationSession;
186
187    fn build(&self) -> RequestBuilder {
188        let session = &self.session;
189        RequestBuilder::new(StripeMethod::Get, format!("/identity/verification_sessions/{session}"))
190            .query(&self.inner)
191    }
192}
193#[derive(Clone, Debug, serde::Serialize)]
194struct CreateIdentityVerificationSessionBuilder {
195    #[serde(skip_serializing_if = "Option::is_none")]
196    client_reference_id: Option<String>,
197    #[serde(skip_serializing_if = "Option::is_none")]
198    expand: Option<Vec<String>>,
199    #[serde(skip_serializing_if = "Option::is_none")]
200    metadata: Option<std::collections::HashMap<String, String>>,
201    #[serde(skip_serializing_if = "Option::is_none")]
202    options: Option<CreateIdentityVerificationSessionOptions>,
203    #[serde(skip_serializing_if = "Option::is_none")]
204    provided_details: Option<ProvidedDetailsParam>,
205    #[serde(skip_serializing_if = "Option::is_none")]
206    related_customer: Option<String>,
207    #[serde(skip_serializing_if = "Option::is_none")]
208    related_person: Option<CreateIdentityVerificationSessionRelatedPerson>,
209    #[serde(skip_serializing_if = "Option::is_none")]
210    return_url: Option<String>,
211    #[serde(rename = "type")]
212    #[serde(skip_serializing_if = "Option::is_none")]
213    type_: Option<CreateIdentityVerificationSessionType>,
214    #[serde(skip_serializing_if = "Option::is_none")]
215    verification_flow: Option<String>,
216}
217impl CreateIdentityVerificationSessionBuilder {
218    fn new() -> Self {
219        Self {
220            client_reference_id: None,
221            expand: None,
222            metadata: None,
223            options: None,
224            provided_details: None,
225            related_customer: None,
226            related_person: None,
227            return_url: None,
228            type_: None,
229            verification_flow: None,
230        }
231    }
232}
233/// A set of options for the session’s verification checks.
234#[derive(Clone, Debug, serde::Serialize)]
235pub struct CreateIdentityVerificationSessionOptions {
236    /// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
237    #[serde(skip_serializing_if = "Option::is_none")]
238    pub document: Option<CreateIdentityVerificationSessionOptionsDocument>,
239}
240impl CreateIdentityVerificationSessionOptions {
241    pub fn new() -> Self {
242        Self { document: None }
243    }
244}
245impl Default for CreateIdentityVerificationSessionOptions {
246    fn default() -> Self {
247        Self::new()
248    }
249}
250/// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
251#[derive(Clone, Debug, serde::Serialize)]
252pub struct CreateIdentityVerificationSessionOptionsDocument {
253    /// Array of strings of allowed identity document types.
254    /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
255    #[serde(skip_serializing_if = "Option::is_none")]
256    pub allowed_types: Option<Vec<CreateIdentityVerificationSessionOptionsDocumentAllowedTypes>>,
257    /// Collect an ID number and perform an [ID number check](https://stripe.com/docs/identity/verification-checks?type=id-number) with the document’s extracted name and date of birth.
258    #[serde(skip_serializing_if = "Option::is_none")]
259    pub require_id_number: Option<bool>,
260    /// Disable image uploads, identity document images have to be captured using the device’s camera.
261    #[serde(skip_serializing_if = "Option::is_none")]
262    pub require_live_capture: Option<bool>,
263    /// Capture a face image and perform a [selfie check](https://stripe.com/docs/identity/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face.
264    /// [Learn more](https://stripe.com/docs/identity/selfie).
265    #[serde(skip_serializing_if = "Option::is_none")]
266    pub require_matching_selfie: Option<bool>,
267}
268impl CreateIdentityVerificationSessionOptionsDocument {
269    pub fn new() -> Self {
270        Self {
271            allowed_types: None,
272            require_id_number: None,
273            require_live_capture: None,
274            require_matching_selfie: None,
275        }
276    }
277}
278impl Default for CreateIdentityVerificationSessionOptionsDocument {
279    fn default() -> Self {
280        Self::new()
281    }
282}
283/// Array of strings of allowed identity document types.
284/// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
285#[derive(Clone, Eq, PartialEq)]
286#[non_exhaustive]
287pub enum CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
288    DrivingLicense,
289    IdCard,
290    Passport,
291    /// An unrecognized value from Stripe. Should not be used as a request parameter.
292    Unknown(String),
293}
294impl CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
295    pub fn as_str(&self) -> &str {
296        use CreateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
297        match self {
298            DrivingLicense => "driving_license",
299            IdCard => "id_card",
300            Passport => "passport",
301            Unknown(v) => v,
302        }
303    }
304}
305
306impl std::str::FromStr for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
307    type Err = std::convert::Infallible;
308    fn from_str(s: &str) -> Result<Self, Self::Err> {
309        use CreateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
310        match s {
311            "driving_license" => Ok(DrivingLicense),
312            "id_card" => Ok(IdCard),
313            "passport" => Ok(Passport),
314            v => {
315                tracing::warn!(
316                    "Unknown value '{}' for enum '{}'",
317                    v,
318                    "CreateIdentityVerificationSessionOptionsDocumentAllowedTypes"
319                );
320                Ok(Unknown(v.to_owned()))
321            }
322        }
323    }
324}
325impl std::fmt::Display for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
326    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
327        f.write_str(self.as_str())
328    }
329}
330
331impl std::fmt::Debug for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
332    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
333        f.write_str(self.as_str())
334    }
335}
336impl serde::Serialize for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
337    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
338    where
339        S: serde::Serializer,
340    {
341        serializer.serialize_str(self.as_str())
342    }
343}
344#[cfg(feature = "deserialize")]
345impl<'de> serde::Deserialize<'de> for CreateIdentityVerificationSessionOptionsDocumentAllowedTypes {
346    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
347        use std::str::FromStr;
348        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
349        Ok(Self::from_str(&s).expect("infallible"))
350    }
351}
352/// Tokens referencing a Person resource and it's associated account.
353#[derive(Clone, Debug, serde::Serialize)]
354pub struct CreateIdentityVerificationSessionRelatedPerson {
355    /// A token representing a connected account.
356    /// If provided, the person parameter is also required and must be associated with the account.
357    pub account: String,
358    /// A token referencing a Person resource that this verification is being used to verify.
359    pub person: String,
360}
361impl CreateIdentityVerificationSessionRelatedPerson {
362    pub fn new(account: impl Into<String>, person: impl Into<String>) -> Self {
363        Self { account: account.into(), person: person.into() }
364    }
365}
366/// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
367/// You must provide a `type` if not passing `verification_flow`.
368#[derive(Clone, Eq, PartialEq)]
369#[non_exhaustive]
370pub enum CreateIdentityVerificationSessionType {
371    Document,
372    IdNumber,
373    /// An unrecognized value from Stripe. Should not be used as a request parameter.
374    Unknown(String),
375}
376impl CreateIdentityVerificationSessionType {
377    pub fn as_str(&self) -> &str {
378        use CreateIdentityVerificationSessionType::*;
379        match self {
380            Document => "document",
381            IdNumber => "id_number",
382            Unknown(v) => v,
383        }
384    }
385}
386
387impl std::str::FromStr for CreateIdentityVerificationSessionType {
388    type Err = std::convert::Infallible;
389    fn from_str(s: &str) -> Result<Self, Self::Err> {
390        use CreateIdentityVerificationSessionType::*;
391        match s {
392            "document" => Ok(Document),
393            "id_number" => Ok(IdNumber),
394            v => {
395                tracing::warn!(
396                    "Unknown value '{}' for enum '{}'",
397                    v,
398                    "CreateIdentityVerificationSessionType"
399                );
400                Ok(Unknown(v.to_owned()))
401            }
402        }
403    }
404}
405impl std::fmt::Display for CreateIdentityVerificationSessionType {
406    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
407        f.write_str(self.as_str())
408    }
409}
410
411impl std::fmt::Debug for CreateIdentityVerificationSessionType {
412    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
413        f.write_str(self.as_str())
414    }
415}
416impl serde::Serialize for CreateIdentityVerificationSessionType {
417    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
418    where
419        S: serde::Serializer,
420    {
421        serializer.serialize_str(self.as_str())
422    }
423}
424#[cfg(feature = "deserialize")]
425impl<'de> serde::Deserialize<'de> for CreateIdentityVerificationSessionType {
426    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
427        use std::str::FromStr;
428        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
429        Ok(Self::from_str(&s).expect("infallible"))
430    }
431}
432/// Creates a VerificationSession object.
433///
434/// After the VerificationSession is created, display a verification modal using the session `client_secret` or send your users to the session’s `url`.
435///
436/// If your API key is in test mode, verification checks won’t actually process, though everything else will occur as if in live mode.
437///
438/// Related guide: [Verify your users’ identity documents](https://stripe.com/docs/identity/verify-identity-documents).
439#[derive(Clone, Debug, serde::Serialize)]
440pub struct CreateIdentityVerificationSession {
441    inner: CreateIdentityVerificationSessionBuilder,
442}
443impl CreateIdentityVerificationSession {
444    /// Construct a new `CreateIdentityVerificationSession`.
445    pub fn new() -> Self {
446        Self { inner: CreateIdentityVerificationSessionBuilder::new() }
447    }
448    /// A string to reference this user.
449    /// This can be a customer ID, a session ID, or similar, and can be used to reconcile this verification with your internal systems.
450    pub fn client_reference_id(mut self, client_reference_id: impl Into<String>) -> Self {
451        self.inner.client_reference_id = Some(client_reference_id.into());
452        self
453    }
454    /// Specifies which fields in the response should be expanded.
455    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
456        self.inner.expand = Some(expand.into());
457        self
458    }
459    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
460    /// This can be useful for storing additional information about the object in a structured format.
461    /// Individual keys can be unset by posting an empty value to them.
462    /// All keys can be unset by posting an empty value to `metadata`.
463    pub fn metadata(
464        mut self,
465        metadata: impl Into<std::collections::HashMap<String, String>>,
466    ) -> Self {
467        self.inner.metadata = Some(metadata.into());
468        self
469    }
470    /// A set of options for the session’s verification checks.
471    pub fn options(mut self, options: impl Into<CreateIdentityVerificationSessionOptions>) -> Self {
472        self.inner.options = Some(options.into());
473        self
474    }
475    /// Details provided about the user being verified. These details may be shown to the user.
476    pub fn provided_details(mut self, provided_details: impl Into<ProvidedDetailsParam>) -> Self {
477        self.inner.provided_details = Some(provided_details.into());
478        self
479    }
480    /// Customer ID
481    pub fn related_customer(mut self, related_customer: impl Into<String>) -> Self {
482        self.inner.related_customer = Some(related_customer.into());
483        self
484    }
485    /// Tokens referencing a Person resource and it's associated account.
486    pub fn related_person(
487        mut self,
488        related_person: impl Into<CreateIdentityVerificationSessionRelatedPerson>,
489    ) -> Self {
490        self.inner.related_person = Some(related_person.into());
491        self
492    }
493    /// The URL that the user will be redirected to upon completing the verification flow.
494    pub fn return_url(mut self, return_url: impl Into<String>) -> Self {
495        self.inner.return_url = Some(return_url.into());
496        self
497    }
498    /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
499    /// You must provide a `type` if not passing `verification_flow`.
500    pub fn type_(mut self, type_: impl Into<CreateIdentityVerificationSessionType>) -> Self {
501        self.inner.type_ = Some(type_.into());
502        self
503    }
504    /// The ID of a verification flow from the Dashboard.
505    /// See <https://docs.stripe.com/identity/verification-flows>.
506    pub fn verification_flow(mut self, verification_flow: impl Into<String>) -> Self {
507        self.inner.verification_flow = Some(verification_flow.into());
508        self
509    }
510}
511impl Default for CreateIdentityVerificationSession {
512    fn default() -> Self {
513        Self::new()
514    }
515}
516impl CreateIdentityVerificationSession {
517    /// Send the request and return the deserialized response.
518    pub async fn send<C: StripeClient>(
519        &self,
520        client: &C,
521    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
522        self.customize().send(client).await
523    }
524
525    /// Send the request and return the deserialized response, blocking until completion.
526    pub fn send_blocking<C: StripeBlockingClient>(
527        &self,
528        client: &C,
529    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
530        self.customize().send_blocking(client)
531    }
532}
533
534impl StripeRequest for CreateIdentityVerificationSession {
535    type Output = stripe_misc::IdentityVerificationSession;
536
537    fn build(&self) -> RequestBuilder {
538        RequestBuilder::new(StripeMethod::Post, "/identity/verification_sessions").form(&self.inner)
539    }
540}
541#[derive(Clone, Debug, serde::Serialize)]
542struct UpdateIdentityVerificationSessionBuilder {
543    #[serde(skip_serializing_if = "Option::is_none")]
544    expand: Option<Vec<String>>,
545    #[serde(skip_serializing_if = "Option::is_none")]
546    metadata: Option<std::collections::HashMap<String, String>>,
547    #[serde(skip_serializing_if = "Option::is_none")]
548    options: Option<UpdateIdentityVerificationSessionOptions>,
549    #[serde(skip_serializing_if = "Option::is_none")]
550    provided_details: Option<ProvidedDetailsParam>,
551    #[serde(rename = "type")]
552    #[serde(skip_serializing_if = "Option::is_none")]
553    type_: Option<UpdateIdentityVerificationSessionType>,
554}
555impl UpdateIdentityVerificationSessionBuilder {
556    fn new() -> Self {
557        Self { expand: None, metadata: None, options: None, provided_details: None, type_: None }
558    }
559}
560/// A set of options for the session’s verification checks.
561#[derive(Clone, Debug, serde::Serialize)]
562pub struct UpdateIdentityVerificationSessionOptions {
563    /// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
564    #[serde(skip_serializing_if = "Option::is_none")]
565    pub document: Option<UpdateIdentityVerificationSessionOptionsDocument>,
566}
567impl UpdateIdentityVerificationSessionOptions {
568    pub fn new() -> Self {
569        Self { document: None }
570    }
571}
572impl Default for UpdateIdentityVerificationSessionOptions {
573    fn default() -> Self {
574        Self::new()
575    }
576}
577/// Options that apply to the [document check](https://stripe.com/docs/identity/verification-checks?type=document).
578#[derive(Clone, Debug, serde::Serialize)]
579pub struct UpdateIdentityVerificationSessionOptionsDocument {
580    /// Array of strings of allowed identity document types.
581    /// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
582    #[serde(skip_serializing_if = "Option::is_none")]
583    pub allowed_types: Option<Vec<UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes>>,
584    /// Collect an ID number and perform an [ID number check](https://stripe.com/docs/identity/verification-checks?type=id-number) with the document’s extracted name and date of birth.
585    #[serde(skip_serializing_if = "Option::is_none")]
586    pub require_id_number: Option<bool>,
587    /// Disable image uploads, identity document images have to be captured using the device’s camera.
588    #[serde(skip_serializing_if = "Option::is_none")]
589    pub require_live_capture: Option<bool>,
590    /// Capture a face image and perform a [selfie check](https://stripe.com/docs/identity/verification-checks?type=selfie) comparing a photo ID and a picture of your user’s face.
591    /// [Learn more](https://stripe.com/docs/identity/selfie).
592    #[serde(skip_serializing_if = "Option::is_none")]
593    pub require_matching_selfie: Option<bool>,
594}
595impl UpdateIdentityVerificationSessionOptionsDocument {
596    pub fn new() -> Self {
597        Self {
598            allowed_types: None,
599            require_id_number: None,
600            require_live_capture: None,
601            require_matching_selfie: None,
602        }
603    }
604}
605impl Default for UpdateIdentityVerificationSessionOptionsDocument {
606    fn default() -> Self {
607        Self::new()
608    }
609}
610/// Array of strings of allowed identity document types.
611/// If the provided identity document isn’t one of the allowed types, the verification check will fail with a document_type_not_allowed error code.
612#[derive(Clone, Eq, PartialEq)]
613#[non_exhaustive]
614pub enum UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
615    DrivingLicense,
616    IdCard,
617    Passport,
618    /// An unrecognized value from Stripe. Should not be used as a request parameter.
619    Unknown(String),
620}
621impl UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
622    pub fn as_str(&self) -> &str {
623        use UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
624        match self {
625            DrivingLicense => "driving_license",
626            IdCard => "id_card",
627            Passport => "passport",
628            Unknown(v) => v,
629        }
630    }
631}
632
633impl std::str::FromStr for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
634    type Err = std::convert::Infallible;
635    fn from_str(s: &str) -> Result<Self, Self::Err> {
636        use UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes::*;
637        match s {
638            "driving_license" => Ok(DrivingLicense),
639            "id_card" => Ok(IdCard),
640            "passport" => Ok(Passport),
641            v => {
642                tracing::warn!(
643                    "Unknown value '{}' for enum '{}'",
644                    v,
645                    "UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes"
646                );
647                Ok(Unknown(v.to_owned()))
648            }
649        }
650    }
651}
652impl std::fmt::Display for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
653    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
654        f.write_str(self.as_str())
655    }
656}
657
658impl std::fmt::Debug for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
659    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
660        f.write_str(self.as_str())
661    }
662}
663impl serde::Serialize for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
664    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
665    where
666        S: serde::Serializer,
667    {
668        serializer.serialize_str(self.as_str())
669    }
670}
671#[cfg(feature = "deserialize")]
672impl<'de> serde::Deserialize<'de> for UpdateIdentityVerificationSessionOptionsDocumentAllowedTypes {
673    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
674        use std::str::FromStr;
675        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
676        Ok(Self::from_str(&s).expect("infallible"))
677    }
678}
679/// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
680#[derive(Clone, Eq, PartialEq)]
681#[non_exhaustive]
682pub enum UpdateIdentityVerificationSessionType {
683    Document,
684    IdNumber,
685    /// An unrecognized value from Stripe. Should not be used as a request parameter.
686    Unknown(String),
687}
688impl UpdateIdentityVerificationSessionType {
689    pub fn as_str(&self) -> &str {
690        use UpdateIdentityVerificationSessionType::*;
691        match self {
692            Document => "document",
693            IdNumber => "id_number",
694            Unknown(v) => v,
695        }
696    }
697}
698
699impl std::str::FromStr for UpdateIdentityVerificationSessionType {
700    type Err = std::convert::Infallible;
701    fn from_str(s: &str) -> Result<Self, Self::Err> {
702        use UpdateIdentityVerificationSessionType::*;
703        match s {
704            "document" => Ok(Document),
705            "id_number" => Ok(IdNumber),
706            v => {
707                tracing::warn!(
708                    "Unknown value '{}' for enum '{}'",
709                    v,
710                    "UpdateIdentityVerificationSessionType"
711                );
712                Ok(Unknown(v.to_owned()))
713            }
714        }
715    }
716}
717impl std::fmt::Display for UpdateIdentityVerificationSessionType {
718    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
719        f.write_str(self.as_str())
720    }
721}
722
723impl std::fmt::Debug for UpdateIdentityVerificationSessionType {
724    fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
725        f.write_str(self.as_str())
726    }
727}
728impl serde::Serialize for UpdateIdentityVerificationSessionType {
729    fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
730    where
731        S: serde::Serializer,
732    {
733        serializer.serialize_str(self.as_str())
734    }
735}
736#[cfg(feature = "deserialize")]
737impl<'de> serde::Deserialize<'de> for UpdateIdentityVerificationSessionType {
738    fn deserialize<D: serde::Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error> {
739        use std::str::FromStr;
740        let s: std::borrow::Cow<'de, str> = serde::Deserialize::deserialize(deserializer)?;
741        Ok(Self::from_str(&s).expect("infallible"))
742    }
743}
744/// Updates a VerificationSession object.
745///
746/// When the session status is `requires_input`, you can use this method to update the
747/// verification check and options.
748#[derive(Clone, Debug, serde::Serialize)]
749pub struct UpdateIdentityVerificationSession {
750    inner: UpdateIdentityVerificationSessionBuilder,
751    session: stripe_misc::IdentityVerificationSessionId,
752}
753impl UpdateIdentityVerificationSession {
754    /// Construct a new `UpdateIdentityVerificationSession`.
755    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
756        Self { session: session.into(), inner: UpdateIdentityVerificationSessionBuilder::new() }
757    }
758    /// Specifies which fields in the response should be expanded.
759    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
760        self.inner.expand = Some(expand.into());
761        self
762    }
763    /// Set of [key-value pairs](https://stripe.com/docs/api/metadata) that you can attach to an object.
764    /// This can be useful for storing additional information about the object in a structured format.
765    /// Individual keys can be unset by posting an empty value to them.
766    /// All keys can be unset by posting an empty value to `metadata`.
767    pub fn metadata(
768        mut self,
769        metadata: impl Into<std::collections::HashMap<String, String>>,
770    ) -> Self {
771        self.inner.metadata = Some(metadata.into());
772        self
773    }
774    /// A set of options for the session’s verification checks.
775    pub fn options(mut self, options: impl Into<UpdateIdentityVerificationSessionOptions>) -> Self {
776        self.inner.options = Some(options.into());
777        self
778    }
779    /// Details provided about the user being verified. These details may be shown to the user.
780    pub fn provided_details(mut self, provided_details: impl Into<ProvidedDetailsParam>) -> Self {
781        self.inner.provided_details = Some(provided_details.into());
782        self
783    }
784    /// The type of [verification check](https://stripe.com/docs/identity/verification-checks) to be performed.
785    pub fn type_(mut self, type_: impl Into<UpdateIdentityVerificationSessionType>) -> Self {
786        self.inner.type_ = Some(type_.into());
787        self
788    }
789}
790impl UpdateIdentityVerificationSession {
791    /// Send the request and return the deserialized response.
792    pub async fn send<C: StripeClient>(
793        &self,
794        client: &C,
795    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
796        self.customize().send(client).await
797    }
798
799    /// Send the request and return the deserialized response, blocking until completion.
800    pub fn send_blocking<C: StripeBlockingClient>(
801        &self,
802        client: &C,
803    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
804        self.customize().send_blocking(client)
805    }
806}
807
808impl StripeRequest for UpdateIdentityVerificationSession {
809    type Output = stripe_misc::IdentityVerificationSession;
810
811    fn build(&self) -> RequestBuilder {
812        let session = &self.session;
813        RequestBuilder::new(
814            StripeMethod::Post,
815            format!("/identity/verification_sessions/{session}"),
816        )
817        .form(&self.inner)
818    }
819}
820#[derive(Clone, Debug, serde::Serialize)]
821struct CancelIdentityVerificationSessionBuilder {
822    #[serde(skip_serializing_if = "Option::is_none")]
823    expand: Option<Vec<String>>,
824}
825impl CancelIdentityVerificationSessionBuilder {
826    fn new() -> Self {
827        Self { expand: None }
828    }
829}
830/// A VerificationSession object can be canceled when it is in `requires_input` [status](https://stripe.com/docs/identity/how-sessions-work).
831///
832/// Once canceled, future submission attempts are disabled.
833/// This cannot be undone.
834/// [Learn more](https://stripe.com/docs/identity/verification-sessions#cancel).
835#[derive(Clone, Debug, serde::Serialize)]
836pub struct CancelIdentityVerificationSession {
837    inner: CancelIdentityVerificationSessionBuilder,
838    session: stripe_misc::IdentityVerificationSessionId,
839}
840impl CancelIdentityVerificationSession {
841    /// Construct a new `CancelIdentityVerificationSession`.
842    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
843        Self { session: session.into(), inner: CancelIdentityVerificationSessionBuilder::new() }
844    }
845    /// Specifies which fields in the response should be expanded.
846    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
847        self.inner.expand = Some(expand.into());
848        self
849    }
850}
851impl CancelIdentityVerificationSession {
852    /// Send the request and return the deserialized response.
853    pub async fn send<C: StripeClient>(
854        &self,
855        client: &C,
856    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
857        self.customize().send(client).await
858    }
859
860    /// Send the request and return the deserialized response, blocking until completion.
861    pub fn send_blocking<C: StripeBlockingClient>(
862        &self,
863        client: &C,
864    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
865        self.customize().send_blocking(client)
866    }
867}
868
869impl StripeRequest for CancelIdentityVerificationSession {
870    type Output = stripe_misc::IdentityVerificationSession;
871
872    fn build(&self) -> RequestBuilder {
873        let session = &self.session;
874        RequestBuilder::new(
875            StripeMethod::Post,
876            format!("/identity/verification_sessions/{session}/cancel"),
877        )
878        .form(&self.inner)
879    }
880}
881#[derive(Clone, Debug, serde::Serialize)]
882struct RedactIdentityVerificationSessionBuilder {
883    #[serde(skip_serializing_if = "Option::is_none")]
884    expand: Option<Vec<String>>,
885}
886impl RedactIdentityVerificationSessionBuilder {
887    fn new() -> Self {
888        Self { expand: None }
889    }
890}
891/// Redact a VerificationSession to remove all collected information from Stripe. This will redact
892/// the VerificationSession and all objects related to it, including VerificationReports, Events,
893/// request logs, etc.
894///
895/// A VerificationSession object can be redacted when it is in `requires_input` or `verified`
896/// [status](https://stripe.com/docs/identity/how-sessions-work).
897/// Redacting a VerificationSession in `requires_action`.
898/// state will automatically cancel it.
899///
900/// The redaction process may take up to four days. When the redaction process is in progress, the
901/// VerificationSession’s `redaction.status` field will be set to `processing`; when the process is
902/// finished, it will change to `redacted` and an `identity.verification_session.redacted` event
903/// will be emitted.
904///
905/// Redaction is irreversible. Redacted objects are still accessible in the Stripe API, but all the
906/// fields that contain personal data will be replaced by the string `[redacted]` or a similar
907/// placeholder. The `metadata` field will also be erased. Redacted objects cannot be updated or
908/// used for any purpose.
909///
910/// [Learn more](https://stripe.com/docs/identity/verification-sessions#redact).
911#[derive(Clone, Debug, serde::Serialize)]
912pub struct RedactIdentityVerificationSession {
913    inner: RedactIdentityVerificationSessionBuilder,
914    session: stripe_misc::IdentityVerificationSessionId,
915}
916impl RedactIdentityVerificationSession {
917    /// Construct a new `RedactIdentityVerificationSession`.
918    pub fn new(session: impl Into<stripe_misc::IdentityVerificationSessionId>) -> Self {
919        Self { session: session.into(), inner: RedactIdentityVerificationSessionBuilder::new() }
920    }
921    /// Specifies which fields in the response should be expanded.
922    pub fn expand(mut self, expand: impl Into<Vec<String>>) -> Self {
923        self.inner.expand = Some(expand.into());
924        self
925    }
926}
927impl RedactIdentityVerificationSession {
928    /// Send the request and return the deserialized response.
929    pub async fn send<C: StripeClient>(
930        &self,
931        client: &C,
932    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
933        self.customize().send(client).await
934    }
935
936    /// Send the request and return the deserialized response, blocking until completion.
937    pub fn send_blocking<C: StripeBlockingClient>(
938        &self,
939        client: &C,
940    ) -> Result<<Self as StripeRequest>::Output, C::Err> {
941        self.customize().send_blocking(client)
942    }
943}
944
945impl StripeRequest for RedactIdentityVerificationSession {
946    type Output = stripe_misc::IdentityVerificationSession;
947
948    fn build(&self) -> RequestBuilder {
949        let session = &self.session;
950        RequestBuilder::new(
951            StripeMethod::Post,
952            format!("/identity/verification_sessions/{session}/redact"),
953        )
954        .form(&self.inner)
955    }
956}
957
958#[derive(Clone, Debug, serde::Serialize)]
959pub struct ProvidedDetailsParam {
960    /// Email of user being verified
961    #[serde(skip_serializing_if = "Option::is_none")]
962    pub email: Option<String>,
963    /// Phone number of user being verified
964    #[serde(skip_serializing_if = "Option::is_none")]
965    pub phone: Option<String>,
966}
967impl ProvidedDetailsParam {
968    pub fn new() -> Self {
969        Self { email: None, phone: None }
970    }
971}
972impl Default for ProvidedDetailsParam {
973    fn default() -> Self {
974        Self::new()
975    }
976}