Integrate Verify with PayPal

DOCS

Last updated: Feb 27th, 8:42am

Integrate Verify with PayPal to confirm PayPal users' identity.

Know before you code

  • Get the following account information from the Developer Dashboard:
    • Client ID and client secret of a REST app.
    • Access token to use the PayPal REST API server.
  • Contact PayPal support to enable Verify with PayPal for your account and provide the following information:
    • Client ID of the sandbox and live REST APP where you want to enable Verify with PayPal.
    • Type of payer data you want to request from PayPal. You can request verified document type, verification status, or both.
  • Verify with PayPal is only available on mobile devices.

1. Set up your app to use Verify with PayPal

Before you can send payers through the verification process, set up your app as follows:

  1. Log into the PayPal Developer Dashboard, go to Apps & Credentials > Sandbox > REST API apps, and select the name of your app.
  2. Go to Sandbox App Settings > App feature options > Log in with PayPal and select Advanced options.
  3. Set a return URL on the application. The return URL should:
    • Connect to your backend that will receive the authorization code, which is passed to paypal.com with a basic header.
    • Support the GET HTTP verb.
  4. Select what information your payers should share with you during the verification process.

3. Create PayPal button

Create a Verify with PayPal button as an anchor tag with the link you created in the previous step.

For help creating the button, see the Log in with PayPal button design guide.

Sample code: Verify with PayPal button

    1<a href="STATIC-LINK-FROM-STEP-2">Verify with PayPal</a>

    4. Exchange authorization code for access token

    After a payer completes the verification process, the payer is redirected to your site. The redirect URL contains an authorization code appended as a query parameter. For example:

    https://example.com?code=AUTH_CODE

    Read the authorization code from the query parameter and pass it to the PayPal API as shown in the following code sample:

    1. Sample request
    2. Sample response
    1curl -X POST 'https://api-m.paypal.com/v1/oauth2/token' -H 'Authorization: Basic YOUR-ACCESS-TOKEN' -H 'Content-Type: application/x-www-form-urlencoded' -d 'grant_type=authorization_code' -d 'code=AUTH_CODE' -d 'response_type=token+id_token' -d 'redirect_uri=https://example.com' -d 'scope=did_tid'

    Step result

    The response includes a user access_token, which you can use in the next step to retrieve the payer verification information. The access token in this response is different from the access token you use to access the PayPal API server.

    If the payer cancels, fails, or declines the verification process, errors are appended to the redirect URL instead.

    Select a tab to view the redirect URL for each error

    1. Cancelled
    2. Failed
    3. Declined
    1https://example.com?errorCode=USER_CANCELLED&errorMessage=user%20cancelled%20verification%20flow

    5. Get payer verification information

    Make a GET request to the Identity API using the user access token from the previous step to retrieve the payer verification information:

    Sample request: Get payer information

      1curl -X GET 'https://api-m.paypal.com/v1/identity/oauth2/userinfo?schema=paypalv1.1' -H 'Authorization: Bearer USER-ACCESS-TOKEN'

      Modify the code

      Replace USER-ACCESS-TOKEN with the access token returned from the previous step

      Sample response

        1{
        2"user_id":"https://www.paypal.com/webapps/auth/identity/user/o6mqLJBHI3c_H77I6mcydoOEvNJbmOaAlVHn9a80VPo",
        3"sub":"https://www.paypal.com/webapps/auth/identity/user/o6mqLJBHI3c_H77I6mcydoOEvNJbmOaAlVHn9a80VPo",
        4"verified_doc_type":"PASSPORT",
        5"verification_status":"COMPLETED"
        6}