PHPackages                             awaisjameel/didit-laravel-client - 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. [API Development](/categories/api)
4. /
5. awaisjameel/didit-laravel-client

ActiveLibrary[API Development](/categories/api)

awaisjameel/didit-laravel-client
================================

A Laravel client library for integrating with the DiDiT verification API. This client handles authentication, session management, PDF report generation, and webhook processing.

v2.0.0(1mo ago)0191[4 PRs](https://github.com/awaisjameel/didit-laravel-client/pulls)MITPHPPHP ^8.1CI passing

Since Jun 23Pushed 1mo ago1 watchersCompare

[ Source](https://github.com/awaisjameel/didit-laravel-client)[ Packagist](https://packagist.org/packages/awaisjameel/didit-laravel-client)[ Docs](https://github.com/awaisjameel/didit-laravel-client)[ GitHub Sponsors]()[ RSS](/packages/awaisjameel-didit-laravel-client/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (14)Versions (6)Used By (0)

DiDiT Laravel Client
====================

[](#didit-laravel-client)

[![Latest Version on Packagist](https://camo.githubusercontent.com/a8c6835b6c37d783d64010e5650b5567a2a6141702ec689a3f8f0733dfbac64d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f61776169736a616d65656c2f64696469742d6c61726176656c2d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/awaisjameel/didit-laravel-client)[![GitHub Tests Action Status](https://camo.githubusercontent.com/22fcf5bdcb302416b469380d4396390779edf2035188642549d6eeb34bbda316/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61776169736a616d65656c2f64696469742d6c61726176656c2d636c69656e742f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/awaisjameel/didit-laravel-client/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/d17a1467f5187e0204cf66e292b7e20748161012eabcbbec487edbf116f8b349/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f61776169736a616d65656c2f64696469742d6c61726176656c2d636c69656e742f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/awaisjameel/didit-laravel-client/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/2cb383376c81ce68aaa1958e3d0712c74268bcf7c1b5e6135fc1cccba6c9216e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f61776169736a616d65656c2f64696469742d6c61726176656c2d636c69656e742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/awaisjameel/didit-laravel-client)

A Laravel client library for integrating with the DiDiT verification API (v3). This client handles authentication, session management, PDF report generation, and webhook processing.

Features
--------

[](#features)

- 🔐 API key authentication (`x-api-key`), with a legacy OAuth2 fallback
- 🔄 Session management (create, retrieve, update) on the Didit **v3** API
- 🧩 Workflow-based sessions (`workflow_id`)
- 📄 PDF report generation
- 🔗 Webhook processing with multiple signature schemes (V2, Simple, legacy)
- 📣 `DiditWebhookReceived` event for listener-based webhook handling
- 🛡️ Timing-attack-safe signature verification
- 🧯 Typed exception hierarchy (`DiditException` and friends)
- 📝 Comprehensive logging options

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

[](#installation)

You can install the package via composer:

```
composer require awaisjameel/didit-laravel-client
```

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --provider="AwaisJameel\DiditLaravelClient\DiditLaravelClientServiceProvider"
```

Add the following environment variables to your `.env` file:

```
# Authentication (recommended): grab your API key from https://business.didit.me
DIDIT_API_KEY=your-api-key

# Default workflow used when creating sessions (configured in the Didit console)
DIDIT_WORKFLOW_ID=your-workflow-uuid

# Endpoints
DIDIT_BASE_URL=https://verification.didit.me
DIDIT_API_VERSION=v3

# Webhooks
DIDIT_WEBHOOK_SECRET=your-webhook-secret

# Misc
DIDIT_TIMEOUT=10
DIDIT_DEBUG=false

# Legacy OAuth2 fallback — only needed if you are NOT using an API key
# DIDIT_CLIENT_ID=your-client-id
# DIDIT_CLIENT_SECRET=your-client-secret
# DIDIT_AUTH_URL=https://apx.didit.me
# DIDIT_TOKEN_EXPIRY_BUFFER=300
```

> **Authentication:** The current Didit API authenticates with a single API key sent in the `x-api-key` header — just set `DIDIT_API_KEY`. The legacy OAuth2 `client_credentials`flow is used automatically only when no API key is configured.

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

```
use AwaisJameel\DiditLaravelClient\Facades\DiditLaravelClient;
// or
use AwaisJameel\DiditLaravelClient\DiditLaravelClient;

// Resolve the shared instance from the container (reads config/.env)
$client = app(DiditLaravelClient::class);

// Or call methods statically through the facade
DiditLaravelClient::createSession(/* ... */);

// Or create a new instance with custom configuration
$client = new DiditLaravelClient([
    'api_key' => 'your-api-key',
    // ... other config options
]);
```

### Creating a Verification Session

[](#creating-a-verification-session)

A session is tied to a **workflow** (configured in the Didit console and identified by a UUID). Provide it via the `workflow_id` option, or set a default with `DIDIT_WORKFLOW_ID`.

```
$session = $client->createSession(
    callbackUrl: 'https://your-app.com/verification/callback', // optional
    vendorData: 'user-123',                                    // optional
    options: [
        'workflow_id' => 'your-workflow-uuid', // falls back to DIDIT_WORKFLOW_ID
        // Any other v3 session fields, e.g.:
        // 'callback_method' => 'both',
        // 'metadata' => json_encode(['plan' => 'pro']),
        // 'contact_details' => ['email' => 'jane@example.com'],
        // 'expected_details' => ['first_name' => 'Jane', 'last_name' => 'Doe'],
    ]
);

// The session response contains:
[
    'session_id' => 'xxx-xxx-xxx',
    'url' => 'https://verify.didit.me/session/xxx',
    // ...
]
```

> If you set `DIDIT_WORKFLOW_ID`, you can simply call `$client->createSession()`.

### Retrieving Session Details

[](#retrieving-session-details)

```
$sessionDetails = $client->getSession('session-id');

// Response contains the full verification decision:
[
    'session_id' => 'xxx-xxx-xxx',
    'status' => 'Approved',
    'id_verifications' => [/* ... */],
    'face_matches' => [/* ... */],
    // ... other decision data
]
```

### Updating Session Status

[](#updating-session-status)

```
$result = $client->updateSessionStatus(
    sessionId: 'session-id',
    newStatus: 'Approved', // 'Approved', 'Declined' or 'Resubmitted'
    comment: 'Verification approved by admin',
    options: [
        // Optional extra fields, e.g.:
        // 'send_email' => true,
        // 'email_address' => 'jane@example.com',
    ]
);
```

### Generating PDF Reports

[](#generating-pdf-reports)

```
$pdfContent = $client->generateSessionPDF('session-id');

// Save to file
file_put_contents('verification-report.pdf', $pdfContent);

// Or return as download response
return response($pdfContent)
    ->header('Content-Type', 'application/pdf')
    ->header('Content-Disposition', 'attachment; filename="report.pdf"');
```

### Handling Webhooks

[](#handling-webhooks)

Set up your webhook route in `routes/web.php`:

```
Route::post('didit/webhook', function (Request $request) {
    $payload = DiditLaravelClient::processWebhook($request);

    // Handle different webhook events by status / type
    match($payload['status'] ?? null) {
        'Approved' => handleApproved($payload),
        'Declined' => handleDeclined($payload),
        default => handleOther($payload)
    };

    return response()->json(['status' => 'processed']);
});
```

`processWebhook()` automatically tries every signature scheme Didit sends (`x-signature-v2`, `x-signature-simple`, then the legacy `x-signature`) and validates the request freshness using `x-timestamp`.

#### Listening for webhook events

[](#listening-for-webhook-events)

After a webhook is verified, `processWebhook()` dispatches a `DiditWebhookReceived` event carrying the verified payload, so you can react in a listener instead of handling everything inline:

```
use AwaisJameel\DiditLaravelClient\Events\DiditWebhookReceived;
use Illuminate\Support\Facades\Event;

Event::listen(function (DiditWebhookReceived $event) {
    match ($event->payload['status'] ?? null) {
        'Approved' => handleApproved($event->payload),
        'Declined' => handleDeclined($event->payload),
        default => handleOther($event->payload),
    };
});
```

Manual webhook signature verification:

```
$headers = [
    'x-signature' => $request->header('x-signature'),
    'x-signature-v2' => $request->header('x-signature-v2'),
    'x-signature-simple' => $request->header('x-signature-simple'),
    'x-timestamp' => $request->header('x-timestamp'),
];

try {
    $payload = $client->verifyWebhookSignature($headers, $request->getContent());
    // Process verified webhook payload
} catch (Exception $e) {
    // Handle invalid signature
    return response()->json(['error' => $e->getMessage()], 400);
}
```

### Error Handling

[](#error-handling)

The client throws a small, typed exception hierarchy so you can catch broadly or narrowly. Every package exception extends `DiditException`, which itself extends `\Exception`:

ExceptionWhen it's thrown`DiditException`Base class — catch this to handle any DiDiT failure`DiditConfigurationException`Missing config (API key/OAuth credentials, base URL, `workflow_id`, webhook secret)`DiditAuthenticationException`Legacy OAuth2 token request failed`DiditRequestException`An API request failed (non-2xx or transport error); exposes `getResponse()` and `status()``WebhookVerificationException`Webhook body/signature/timestamp could not be verifiedInvalid method arguments (e.g. an empty session id or an unknown status) throw `\InvalidArgumentException`.

```
use AwaisJameel\DiditLaravelClient\Exceptions\DiditException;
use AwaisJameel\DiditLaravelClient\Exceptions\DiditRequestException;

try {
    $session = $client->createSession(/* ... */);
} catch (DiditRequestException $e) {
    // Inspect the HTTP response from Didit
    Log::error('DiDiT API Error', [
        'status' => $e->status(),
        'body' => optional($e->getResponse())->json(),
    ]);
} catch (DiditException $e) {
    // Any other DiDiT failure (config, auth, webhook, ...)
    Log::error('DiDiT Error: '.$e->getMessage());
}
```

### Debugging

[](#debugging)

Enable debug mode in your configuration to get detailed logging:

```
// In your .env file
DIDIT_DEBUG=true

// Or in configuration
$client = new DiditLaravelClient([
    // ... other config
    'debug' => true
]);
```

Debug logs will include:

- API requests and responses
- Token management events
- Webhook processing details
- Error details

> ⚠️ **Debug logs may contain PII.** When `DIDIT_DEBUG=true`, verification payloads and API responses (which can include personal/identity data) are written to your application log. Keep debug mode off in production, or ensure your logs are access-controlled and retained appropriately.

Testing
-------

[](#testing)

The package includes comprehensive tests. Run them with:

```
composer test
```

Security
--------

[](#security)

- All API requests use HTTPS
- Webhook signatures are verified using HMAC SHA-256 (V2, Simple and legacy schemes)
- Timing attack safe signature comparison
- API key sent via the `x-api-key` header. On the legacy OAuth fallback, access tokens are cached through Laravel's cache store (shared across requests/workers) and refreshed automatically before expiry
- Request timestamp validation (rejects stale webhooks older than 5 minutes)

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Awais Jameel](https://github.com/awaisjameel)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance90

Actively maintained with recent releases

Popularity13

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 68% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8478f5cd00831255bda5f4ab259a8761a8001142756ab90bf8804388a78b2036?d=identicon)[awaisjameel](/maintainers/awaisjameel)

---

Top Contributors

[![awaisjameel](https://avatars.githubusercontent.com/u/9046343?v=4)](https://github.com/awaisjameel "awaisjameel (17 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

laraveldiditAwais Jameeldidit-laravel-client

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/awaisjameel-didit-laravel-client/health.svg)

```
[![Health](https://phpackages.com/badges/awaisjameel-didit-laravel-client/health.svg)](https://phpackages.com/packages/awaisjameel-didit-laravel-client)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[simplestats-io/laravel-client

Server-side analytics for Laravel that follows the full funnel from visit to registration to payment, attributed to the channel that drove it. Revenue, MRR, churn and ad-spend profit (ROAS/CAC) per channel. GDPR compliant, ad-blocker proof.

5226.7k](/packages/simplestats-io-laravel-client)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M211](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)[harris21/laravel-fuse

Circuit breaker for Laravel queue jobs. Protect your workers from cascading failures.

46273.9k](/packages/harris21-laravel-fuse)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
