Ngx Stripe
  • Introduction
  • Getting Started
    • Installation
    • Setup Application
  • Core Concepts
    • Checkout
    • Payment Element
    • Element Components
    • Identity
    • Payment Request Button
    • Service
    • Styling
    • Service Factory
    • Reference & Instance
    • Manually Mount your Element
  • Support
  • FAQS
  • Examples
  • Migration
Powered by GitBook
On this page
  • Verify your users identity documents
  • Verify your users identity using redirect

Was this helpful?

  1. Core Concepts

Identity

The easiest way to verify identities

PreviousElement ComponentsNextPayment Request Button

Last updated 3 years ago

Was this helpful?

Stripe Identity helps you confirm the identity of global users to prevent fraud, streamline risk operations, and increase trust and safety.

  • Capture IDs with a conversion-optimized verification flow

  • Verify authenticity of global ID documents

  • Match photo ID with selfies, and validate SSN

  • Access collected images, and extracted data from ID document

If you want to know more, please visit the home page. Or, if you're ready to get started, you can check the docs

In order to use Stripe Identity you first need to Activate your account and fill out your .

Verify your users identity documents

There are four ways to implement Identity:

  • Modal — show a document upload modal inside your website.

  • Redirect — send your users to Stripe to upload their identity documents.

  • iOS Beta — show a document upload sheet inside your app.

  • Without code — manually create verifications in Dashboard and share a link with your users.

In this case we are going to use ngx-stripe to trigger the modal window within our Angular App. We need to create a verificación session in the server and then use the client secret in the front to trigger open the modal. Is a very similar to the flow.

To see more details on a full example, please check the official .

import { Component } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { switchMap } from 'rxjs/operators';

import { StripeService } from 'ngx-stripe';

@Component({
  selector: 'app-identity',
  templateUrl: './identity.component.html'
})
export class IdentityComponent {
  constructor(
    private http: HttpClient,
    private stripeService: StripeService
  ) {}

  verify() {
    // Check the server.js tab to see an example implementation
    this.https.post('/create-verification-session', {})
      .pipe(
        switchMap(session => {
          // Show the verification modal.
          return this.stripeService.verifyIdentity(session.clientSecret)
        })
      )
      .subscribe(result => {
        // If `verifyIdentity` fails, you should display the localized
        // error message to your user using `error.message`.
        if (result.error) {
          alert(result.error.message);
        }
      });
  }
}
<button (click)="verify()">
    VERIFY
</button>
// This example sets up an endpoint using the Express framework.
// Watch this video to get started: https://youtu.be/rPR2aJ6XnAc.

const express = require('express');
const app = express();
const stripe = require('stripe')('***your secret key***');

app.post('/create-verification-session', async (req, res) => {
  const verificationSession = await stripe.identity.verificationSessions.create({
    type: 'document',
    metadata: {
      user_id: '{{USER_ID}}',
    }
  });

  // Return only the client secret to the frontend
  res.json({ clientSecret: verificationSession.clientSecret });
});

app.listen(4242, () => console.log(`Listening on port ${4242}!`));

Verify your users identity using redirect

As discuss in the previous section, there is an alternative flow using redirect instead of a modal window. In this case you don't need this library or to bootstrap Stripe in the front at all.

All you need is to create a Verification Session in the server and pass the redirect url to the front. From there, you can simply redirect the user to that url.

import { Component, Inject } from '@angular/core';
import { DOCUMENT } from '@angular/common';
import { HttpClient } from '@angular/common/http';
import { switchMap } from 'rxjs/operators';

@Component({
  selector: 'app-identity',
  templateUrl: './identity.component.html'
})
export class IdentityComponent {
  constructor(
    @Inject(DOCUMENT) private document: Document,
    private http: HttpClient
  ) {}

  verify() {
    // Check the server.js tab to see an example implementation
    this.https.post('/create-verification-session', {})
      .subscribe(session => {
        this.document.location.href = session.url;
      });
  }
}
<button (click)="verify()">
    VERIFY
</button>
// This example sets up an endpoint using the Express framework.
// Watch this video to get started: https://youtu.be/rPR2aJ6XnAc.

const express = require('express');
const app = express();
const stripe = require('stripe')('***your secret key***');

app.post('/create-verification-session', async (req, res) => {
  const verificationSession = await stripe.identity.verificationSessions.create({
    type: 'document',
    metadata: {
      user_id: '{{USER_ID}}',
    }
  });

  // Return only the session URL to the frontend
  res.json({ url: verificationSession.url });
});

app.listen(4242, () => console.log(`Listening on port ${4242}!`));

Again, to see more details on a full example, please check the official .

Stripe Identity
here
Stripe Identity application
Checkout
Stripe Docs
Stripe Docs