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