PHPackages                             verifymyagecouk/verifymyage-oauth - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. verifymyagecouk/verifymyage-oauth

ActiveProject[Authentication &amp; Authorization](/categories/authentication)

verifymyagecouk/verifymyage-oauth
=================================

VerifyMyAge OAuth Verification

3.1.2(2mo ago)4123.2k—9.7%5[1 issues](https://github.com/verifymyagecouk/verifymyage-oauth/issues)[3 PRs](https://github.com/verifymyagecouk/verifymyage-oauth/pulls)MITPHP

Since May 19Pushed 2mo ago3 watchersCompare

[ Source](https://github.com/verifymyagecouk/verifymyage-oauth)[ Packagist](https://packagist.org/packages/verifymyagecouk/verifymyage-oauth)[ RSS](/packages/verifymyagecouk-verifymyage-oauth/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)Dependencies (2)Versions (29)Used By (0)

VerifyMyAge PHP SDK
===================

[](#verifymyage-php-sdk)

A PHP SDK for integrating with VerifyMyAge's verification service. This library provides easy-to-use methods for implementing age verification in your PHP applications.

Table of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Features](#features)
- [Usage](#usage)
    - [Basic Setup](#basic-setup)
    - [Available Methods](#available-methods)
    - [Verification Methods](#verification-methods)
    - [Verification Status](#verification-status-oauthv1--oauthv2)
    - [Supported Countries](#supported-countries)
- [Examples](#examples)
- [Development Mode](#development-mode)

Installation
------------

[](#installation)

```
composer require verifymyagecouk/verifymyage-oauth
```

Features
--------

[](#features)

- Authentication flow
- Multiple verification methods
- Support for various countries
- Sandbox environment for testing
- HMAC authentication
- User data encryption

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
use VerifyMyAge\OAuth;

// Initialize the OAuth client
$oauth = new OAuth(
    'your-client-id',
    'your-client-secret',
    'your-redirect-url'
);

// For development/testing, use sandbox mode
$oauth->useSandbox();
```

### Available Methods

[](#available-methods)

The SDK provides three different versions of the OAuth implementation:

1. **OAuth (Legacy)**:

```
use VerifyMyAge\OAuth;
$oauth = new OAuth($clientId, $clientSecret, $redirectUrl);
```

2. **OAuthV1**:

```
use VerifyMyAge\OAuthV1;
$oauth = new OAuthV1($clientId, $clientSecret, $redirectUrl);
```

3. **OAuthV2** (Recommended):

```
use VerifyMyAge\OAuthV2;
$oauth = new OAuthV2($clientId, $clientSecret, $redirectUrl);
```

### Verification Methods

[](#verification-methods)

Available verification methods:

```
Methods::AGE_ESTIMATION
Methods::CREDIT_CARD
Methods::ID_SCAN
Methods::ID_SCAN_FACE_MATCH
Methods::EMAIL
```

### Webhook Notification Levels

[](#webhook-notification-levels)

Available webhook notification levels:

```
Webhook::MINIMAL_NOTIFICATION_LEVEL
Webhook::METHOD_EXHAUSTED_NOTIFICATION_LEVEL
Webhook::DETAILED_NOTIFICATION_LEVEL
```

### Starting Verification (OAuthV2)

[](#starting-verification-oauthv2)

```
$result = $oauth->getStartVerificationUrl(
    country: Countries::UNITED_KINGDOM,
    method: Methods::ID_SCAN,
    businessSettingsId: 'your-business-settings-id',
    externalUserId: 'user-123',
    verificationId: 'verification-123',
    webhook: 'https://your-webhook.com/callback',
    webhookNotificationLevel: Webhook::DETAILED_NOTIFICATION_LEVEL,
    stealth: false,
    userInfo: [
        'email' => 'user@example.com'
        // Additional user information
    ]
);
```

### Handling the OAuth Flow

[](#handling-the-oauth-flow)

1. **Generate Authorization URL**:

```
$authUrl = $oauth->redirectURL(
    country: Countries::UNITED_KINGDOM,
    method: Methods::ID_SCAN
);
```

2. **Exchange Code for Token**:

After the user completes the verification process with us, we will redirect the user back to you using your redirect URL provided to us in the first step, we will keep all the query strings you've sent and also add two new ones, First as **code** and Second as **verification\_id**. The **code** must be used in this function, so we can authenticate your request and identify the verification that you want to get the result.

```
$token = $oauth->exchangeCodeByToken($code);
```

### Supported Countries

[](#supported-countries)

The SDK supports various countries including:

- Australia (`Countries::AUSTRALIA`)
- Brazil (`Countries::BRAZIL`)
- Spain (`Countries::SPAIN`)
- United Kingdom (`Countries::UNITED_KINGDOM`)
- France (`Countries::FRANCE`)
- Germany (`Countries::GERMANY`)
- United States (`Countries::UNITED_STATES_OF_AMERICA`)
- Ireland (`Countries::IRELAND`)
- Italy (`Countries::ITALY`)
- Demo mode (`Countries::DEMO`)

Development Mode
----------------

[](#development-mode)

For testing and development, use the sandbox environment:

```
$oauth->useSandbox();
```

This will direct all requests to the sandbox API endpoint.

Complete Example
----------------

[](#complete-example)

Here's a complete example of implementing age verification:

```
