Verify your users’ identity documents
Create sessions and collect identity documents.
This guide explains how to use Stripe Identity to securely collect and verify identity documents.
Before you begin
- Activate your account.
- Fill out your Stripe Identity application.
- (Optional) Customize your brand settings on the branding settings page.
Note
To get access to the Identity React Native SDK, visit the Identity Settings page and click Enable.
To verify the identity of your users on React Native, present a verification sheet in your application. This guide includes the following steps:
- Set up Stripe.
- Add a server endpoint.
- Present the verification sheet.
- Handle verification events.
The steps in this guide are fully implemented in the example app and example backend server.
Set upServer-sideClient-side
Install the SDK Client-side
The React Native SDK is open source, fully documented, and compatible with apps supporting iOS 13.0 or Android 5.0 (API level 21) and above. Internally, it uses native iOS and Android SDKs.
Install the SDK by running:
Note
For details on the latest SDK release and past versions, see the Releases page on GitHub. To receive notifications when a new release is published, watch releases for the repository.
For iOS, run pod install
in the ios
directory to ensure that you also install the required native dependencies. Android doesn’t require any additional steps.
Set up camera authorization for iOS Client-side
The Stripe Identity iOS SDK requires access to the device’s camera to capture identity documents. To enable your app to request camera permissions:
- Open your project’s Info.plist in Xcode.
- Add the
NSCameraUsageDescription
key. - Add a string value that explains to your users why your app requires camera permissions, something such as:
This app uses the camera to take a picture of your identity documents.
See Apple’s documentation to learn more about requesting camera authorization.
Set up material theme for Android Client-side
The Stripe Identity Android SDK requires the hosting activity to use material theme. To enable material theme:
- Open your project’s
app/src/main/AndroidManifest.
.xml - Make sure the
android:theme
applied to theapplication
is a child of one of the material themes(for example,Theme.
).MaterialComponents. DayNight
See more details about material theme here.
Install Stripe on your server Server-side
First, register for a Stripe account.
Then install the libraries for access to the Stripe API from your application:
Add a server endpointServer-side
Create a VerificationSession
A VerificationSession is the programmatic representation of the verification. It contains details about the type of verification, such as what check to perform. You can expand the verified outputs field to see details of the data that was verified.
You need a server-side endpoint to create the VerificationSession. Creating the VerificationSession
server-side prevents malicious users from overriding verification options and incurring processing charges on your account. Add authentication to this endpoint by including a user reference in the session metadata or storing the session ID in your database.
For security, don’t create a VerificationSession
object that’s directly accessible from the mobile client. Instead, your server provides the SDK with an ephemeral key — a short-lived API key with restricted access to the VerificationSession. You can think of an ephemeral key as a session, authorizing the SDK to retrieve and update a specific VerificationSession
object for the duration of the session.
After successfully creating a VerificationSession
and ephemeral key, send the VerificationSession
ID and ephemeral key secret to the client to show the document upload sheet.
Note
You can find a running implementation of this endpoint available on Glitch for quick testing.
Caution
The ephemeral key secret is bound to the VerificationSession
and lets your app collect sensitive verification information such as document and selfie image files. It’s single-use and expires after 1 hour. Don’t store it, log it, embed it in a URL, or expose it to anyone other than the user. Make sure that you have TLS enabled on any endpoint that returns the ephemeral key secret. Send only the ephemeral key secret to your app to avoid exposing verification configuration or results.
Test your endpoint by starting your web server (for example, localhost:4242
) and sending a POST request with curl to create a VerificationSession:
curl -X POST -is "http://localhost:4242/create-verification-session" -d ""
The response in your terminal looks like this:
HTTP/1.1 200 OK Content-Type: application/json { id: "vs_QdfQQ6xfGNJR7ogV6", ephemeral_key_secret: "ek_YWNjdF8xRm..." }
Present the verification sheetClient-side
Set up a button to present a verification sheet. After tapping the button, your user can capture and upload a picture of their passport, driver’s license, or national ID.
Before getting started, your verification page should:
- Explain to the user why they need to verify their identity.
- Include a verify identity button to present Stripe’s UI.
Add a button
Start by creating a Button component:
import React from 'react'; import { View, Button, } from 'react-native'; function VerifyScreen() { return ( <View> <Button title='Verify' /> </View> ); }
Import the Stripe Identity SDK
Import the useStripeIdentity
hook:
import React from 'react'; import { View, Button, } from 'react-native'; import { useStripeIdentity } from "@stripe/stripe-identity-react-native"; function VerifyScreen() { return ( <View> <Button title='Verify' /> </View> ); }
Add an event handler to the Verify button
Now that you have a button and an endpoint to create a VerificationSession, modify the button so that it presents the document upload sheet when tapped.
Add a call to:
- Fetch the
VerificationSession
ID and ephemeral key secret from your endpoint. - Instantiate the
useStripeIdentity
hook by passingfetchOptions
with your brand logo and presenting it to the user. - Handle the
status
to know if the user completed the verification flow.
import React from 'react'; import { View, Button, Text, Image } from 'react-native'; import { useStripeIdentity } from "@stripe/stripe-identity-react-native"; // A square logo for your brand import logo from './assets/{{YOUR_BRAND_LOGO}}.png'; function VerifyScreen() { const fetchVerificationSessionParams = async () => { try { const data = await fetch(`${YOUR_SERVER_BASE_URL}/create-verification-session`, { method: 'POST', headers: { 'Content-Type': 'application/json', }, }); const json = await data.json(); return json; } catch (e) { return {}; } }; const fetchOptions = async () => { const response = await fetchVerificationSessionParams(); return { sessionId: response.id, ephemeralKeySecret: response.ephemeral_key_secret, brandLogo: Image.resolveAssetSource(logo), }; }; const { status, present, loading } = useStripeIdentity(fetchOptions); const handlePress = React.useCallback(() => { present(); }, [present]); return ( <View> <Button title='Verify' disabled={loading} onPress={handlePress} /> <Text>Status: {status}</Text> </View> ); }
Test the verification sheet
Test that the verify button presents a document upload sheet:
- Tap the Verify Identity button.
- Ensure no error messages are shown.
If your integration isn’t working:
- Put a breakpoint where you fetch the
VerificationSession
ID and ephemeral key secret. - Verify that no network errors exist and that the endpoint is returning a
VerificationSession
ID and ephemeral key secret.
Handle verification events
Document checks are typically completed as soon as the user redirects back to your site and you can retrieve the result from the API immediately. In some rare cases, the document verification isn’t ready yet and must continue asynchronously. In these cases, you’re notified through webhooks when the verification result is ready. After the processing completes, the VerificationSession status changes from processing
to verified
.
Stripe sends the following events when the session status changes:
Event name | Description | Next steps |
---|---|---|
identity.verification_session.verified | Processing of all the verification checks have completed, and they’re all successfully verified. | Trigger relevant actions in your application. |
identity.verification_session.requires_input | Processing of all the verification checks have completed, and at least one of the checks failed. | Trigger relevant actions in your application and potentially allow your user to retry the verification. |
Use a webhook handler to receive these events and automate actions like sending a confirmation email, updating the verification results in your database, or completing an onboarding step. You can also view verification events in the Dashboard.
Receive events and run business actions
With code
Build a webhook handler to listen for events and build custom asynchronous verification flows. Test and debug your webhook integration locally with the Stripe CLI.
Without code
Use the Dashboard to view all your verifications, inspect collected data, and understand verification failures.