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.

0148↓100%[4 PRs](https://github.com/awaisjameel/didit-laravel-client/pulls)PHPCI passing

Since Oct 13Pushed 1mo ago1 watchersCompare

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

READMEChangelogDependenciesVersions (4)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. This client handles authentication, session management, PDF report generation, and webhook processing.

Features
--------

[](#features)

- 🔐 OAuth2 Authentication with automatic token management
- 🔄 Session management (create, retrieve, update)
- 📄 PDF report generation
- 🔗 Webhook processing with signature verification
- ⚡ Request caching and optimization
- 🛡️ Secure webhook signature verification
- 📝 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:

```
DIDIT_CLIENT_ID=your-client-id
DIDIT_CLIENT_SECRET=your-client-secret
DIDIT_BASE_URL=https://verification.didit.me
DIDIT_AUTH_URL=https://apx.didit.me
DIDIT_WEBHOOK_SECRET=your-webhook-secret
DIDIT_TIMEOUT=10
DIDIT_TOKEN_EXPIRY_BUFFER=300
DIDIT_DEBUG=false
```

Usage
-----

[](#usage)

### Basic Setup

[](#basic-setup)

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

// Using the facade
$client = DiditLaravelClient::getInstance();

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

### Creating a Verification Session

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

```
$session = $client->createSession(
    callbackUrl: 'https://your-app.com/verification/callback',
    vendorData: 101,
    options: [
        'features'=> 'OCR + NFC + FACE'
    ]
);

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

### Retrieving Session Details

[](#retrieving-session-details)

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

// Response contains verification details:
[
    'session_id' => 'xxx-xxx-xxx',
    'status' => 'completed',
    'decision' => 'approved',
    // ... other session data
]
```

### Updating Session Status

[](#updating-session-status)

```
$result = $client->updateSessionStatus(
    sessionId: 'session-id',
    newStatus: 'Approved', // or 'Declined'
    comment: 'Verification approved by admin'
);
```

### 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
    match($payload['event']) {
        'verification.completed' => handleVerificationCompleted($payload),
        'verification.expired' => handleVerificationExpired($payload),
        default => handleUnknownEvent($payload)
    };

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

Manual webhook signature verification:

```
$headers = [
    'x-signature' => $request->header('x-signature'),
    '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 exceptions for various error conditions. It's recommended to wrap API calls in try-catch blocks:

```
try {
    $session = $client->createSession(...);
} catch (Exception $e) {
    // Handle error
    Log::error('DiDiT API Error: ' . $e->getMessage());
}
```

Common exceptions:

- Configuration errors (missing credentials)
- Authentication failures
- Invalid session IDs
- Network/API errors
- Invalid webhook signatures

### 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

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
- Timing attack safe signature comparison
- Automatic token expiry management
- Request timestamp validation

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

25

—

LowBetter than 37% of packages

Maintenance59

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity17

Early-stage or recently created project

 Bus Factor1

Top contributor holds 60% 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.

### 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 (12 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)")

### 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

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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