PHPackages                             asciisd/kyc-core - 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. asciisd/kyc-core

ActiveLibrary

asciisd/kyc-core
================

Core KYC (Know Your Customer) functionality for Laravel applications with enhanced webhook data merging

1.9.0(1mo ago)0441↓40%1MITPHPPHP ^8.3

Since Sep 14Pushed 1mo agoCompare

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

READMEChangelog (1)Dependencies (10)Versions (12)Used By (1)

Asciisd KYC Core
================

[](#asciisd-kyc-core)

[![Latest Version on Packagist](https://camo.githubusercontent.com/452defe6477a6387a2b60fc620aa7017c99b5386759cabf45249fc8dfbb5a2cd/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f617363696973642f6b79632d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/kyc-core)[![Total Downloads](https://camo.githubusercontent.com/104bcc480f0074e4846fbc7911d7fbd966d7c99dab475791625b6c3546e6defe/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f617363696973642f6b79632d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/kyc-core)[![License](https://camo.githubusercontent.com/d2a3274d7a1800a5d2c7df5046eef0333803c498179101ca68e94830a9b4c026/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f617363696973642f6b79632d636f72652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/asciisd/kyc-core)

A comprehensive Laravel package for KYC (Know Your Customer) verification management. This package provides a clean, extensible architecture for integrating multiple KYC providers with **automatic infrastructure routes** and **provider-agnostic status mapping**.

✨ Key Features
--------------

[](#-key-features)

- **🚀 Zero-Config Infrastructure**: Webhook routes automatically registered - no setup required!
- **🔄 Provider-Agnostic Architecture**: Seamlessly switch between KYC providers (ShuftiPro, Jumio, Onfido, etc.)
- **🎯 Driver-Based Status Mapping**: Each provider handles its own event-to-status mapping
- **📡 Auto-Registered Routes**: Infrastructure routes work out-of-the-box
- **🎪 Event-Driven**: Comprehensive event system for verification lifecycle
- **📊 Smart Status Management**: Intelligent status tracking and transitions
- **📁 Document Management**: Built-in document storage and retrieval
- **🔒 Secure Webhooks**: Signature validation and comprehensive logging
- **✅ Built-in Validation**: Request validation and user eligibility checks
- **🔍 Comprehensive Logging**: Detailed logging for debugging and monitoring
- **🔗 Morphable Models**: Works with any Eloquent model using morphable relationships

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

[](#installation)

```
composer require asciisd/kyc-core
```

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

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=kyc-config
```

Publish the migrations:

```
php artisan vendor:publish --tag=kyc-migrations
```

Run the migrations:

```
php artisan migrate
```

🚀 Automatic Infrastructure Routes
---------------------------------

[](#-automatic-infrastructure-routes)

**NEW!** The package now automatically registers infrastructure routes - no manual setup required!

### Auto-Registered Routes

[](#auto-registered-routes)

When you install the package, these routes are automatically available:

```
// Webhook endpoints (no authentication required)
POST   /api/kyc/webhook                 // Main webhook handler
POST   /api/kyc/webhook/callback        // Alternative webhook endpoint
GET    /api/kyc/verification/complete   // Verification completion callback
GET    /api/kyc/health                  // Health check endpoint

// Backward compatibility (without /api prefix)
POST   /kyc/webhook
POST   /kyc/webhook/callback
GET    /kyc/verification/complete
GET    /kyc/health
```

### Benefits

[](#benefits)

- ✅ **Zero Configuration** - Works immediately after installation
- ✅ **Consistent Behavior** - Same webhook handling across all applications
- ✅ **Provider Agnostic** - Works with any KYC driver
- ✅ **Automatic Updates** - Bug fixes and improvements benefit all apps
- ✅ **Simplified Integration** - Focus on business logic, not infrastructure

### Health Check

[](#health-check)

Monitor your KYC system health:

```
curl https://yourdomain.com/api/kyc/health
```

```
{
    "success": true,
    "message": "KYC infrastructure is healthy",
    "default_driver": "shuftipro",
    "available_drivers": ["shuftipro", "jumio", "onfido"],
    "enabled_drivers": ["shuftipro"]
}
```

🚀 Quick Start
-------------

[](#-quick-start)

### Minimal Setup (3 Steps!)

[](#minimal-setup-3-steps)

1. **Install the package**

    ```
    composer require asciisd/kyc-core asciisd/kyc-shuftipro
    ```
2. **Publish and run migrations**

    ```
    php artisan vendor:publish --tag=kyc-migrations
    php artisan migrate
    ```
3. **Add trait to your User model**

    ```
    use Asciisd\KycCore\Traits\HasKycVerification;

    class User extends Model
    {
        use HasKycVerification;
    }
    ```

**That's it!** 🎉 Infrastructure routes are automatically registered. Just configure your KYC provider credentials and start verifying users.

Usage
-----

[](#usage)

### Basic Usage

[](#basic-usage)

```
use Asciisd\KycCore\Facades\Kyc;
use Asciisd\KycCore\DTOs\KycVerificationRequest;

// Create a verification request
$request = new KycVerificationRequest(
    email: 'user@example.com',
    country: 'US',
    language: 'en'
);

// Start verification
$response = Kyc::createVerification($user, $request);

// Process webhook
$webhookResponse = Kyc::processWebhook($payload, $headers);
```

### Model Integration

[](#model-integration)

Add the trait to your User model:

```
use Asciisd\KycCore\Traits\HasKycVerification;

class User extends Model
{
    use HasKycVerification;

    // Your model code...
}
```

Now you can use KYC methods on your user:

```
// Check if user can start KYC
if ($user->canStartKyc()) {
    // Start verification process
}

// Check if user has completed KYC
if ($user->hasCompletedKyc()) {
    // User is verified
}

// Get current KYC status
$status = $user->getKycStatus();
```

### Events

[](#events)

The package fires several events you can listen to:

```
use Asciisd\KycCore\Events\VerificationStarted;
use Asciisd\KycCore\Events\VerificationCompleted;
use Asciisd\KycCore\Events\VerificationFailed;

// Listen for events
Event::listen(VerificationStarted::class, function ($event) {
    Log::info('Verification started for user: ' . $event->user->id);
});
```

### Status Management

[](#status-management)

The package includes a comprehensive status enum:

```
use Asciisd\KycCore\Enums\KycStatusEnum;

// Check status properties
if ($status->isCompleted()) {
    // Handle completed verification
}

if ($status->needsAction()) {
    // User needs to take action
}

// Get human-readable label
$label = $status->label(); // "KYC Completed"
$color = $status->color(); // "green"
```

🏗️ Advanced Driver Architecture
-------------------------------

[](#️-advanced-driver-architecture)

The package uses a sophisticated driver-based architecture with **provider-specific status mapping**:

```
interface KycDriverInterface
{
    // Core verification methods
    public function createVerification(Model $user, KycVerificationRequest $request): KycVerificationResponse;
    public function retrieveVerification(string $reference): KycVerificationResponse;
    public function processWebhook(array $payload, array $headers = []): KycVerificationResponse;
    public function downloadDocuments(Model $user, string $reference): array;

    // Driver information
    public function getName(): string;
    public function isEnabled(): bool;
    public function getCapabilities(): array;

    // 🆕 NEW: Provider-specific status mapping
    public function mapEventToStatus(string $event): KycStatusEnum;
}
```

### 🎯 Provider-Specific Status Mapping

[](#-provider-specific-status-mapping)

Each driver handles its own event-to-status mapping, making the system truly provider-agnostic:

```
// ShuftiPro Driver
public function mapEventToStatus(string $event): KycStatusEnum
{
    return match ($event) {
        'verification.completed' => KycStatusEnum::Completed,
        'verification.declined' => KycStatusEnum::Rejected,
        'verification.pending' => KycStatusEnum::InProgress,
        // ... ShuftiPro-specific events
    };
}

// Jumio Driver (example)
public function mapEventToStatus(string $event): KycStatusEnum
{
    return match ($event) {
        'SUCCESS' => KycStatusEnum::Completed,
        'ERROR' => KycStatusEnum::VerificationFailed,
        'INITIATED' => KycStatusEnum::InProgress,
        // ... Jumio-specific events
    };
}
```

### Benefits

[](#benefits-1)

- ✅ **Provider Independence** - Each provider handles its own event mapping
- ✅ **Easy Migration** - Switch providers without changing application logic
- ✅ **Extensible** - Add new providers by implementing the interface
- ✅ **Consistent** - Standardized KYC status across all providers

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

[](#configuration-1)

The package configuration allows you to:

- Set default driver
- Configure multiple drivers
- Set verification settings
- Define supported/restricted countries
- Configure document storage

```
// config/kyc.php
return [
    'default_driver' => 'shuftipro',
    'drivers' => [
        'shuftipro' => [
            'enabled' => true,
            'class' => 'Asciisd\\KycShuftiPro\\Drivers\\ShuftiProDriver',
            // ...
        ],
    ],
    'settings' => [
        'require_email_verification' => true,
        'max_verification_attempts' => 3,
        // ...
    ],
];
```

Testing
-------

[](#testing)

```
composer test
```

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

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance88

Actively maintained with recent releases

Popularity17

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

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

Every ~19 days

Recently: every ~4 days

Total

11

Last Release

58d ago

PHP version history (2 changes)v1.0.0PHP ^8.2

1.9.0PHP ^8.3

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77636067?v=4)[ASCII SD](/maintainers/asciisd)[@asciisd](https://github.com/asciisd)

---

Top Contributors

[![aemaddin](https://avatars.githubusercontent.com/u/11630742?v=4)](https://github.com/aemaddin "aemaddin (22 commits)")

###  Code Quality

TestsPest

### Embed Badge

![Health badge](/badges/asciisd-kyc-core/health.svg)

```
[![Health](https://phpackages.com/badges/asciisd-kyc-core/health.svg)](https://phpackages.com/packages/asciisd-kyc-core)
```

###  Alternatives

[anourvalar/eloquent-serialize

Laravel Query Builder (Eloquent) serialization

11320.2M21](/packages/anourvalar-eloquent-serialize)[namu/wirechat

A Laravel Livewire messaging app for teams with private chats and group conversations.

54324.5k](/packages/namu-wirechat)[statamic-rad-pack/runway

Eloquently manage your database models in Statamic.

135192.6k5](/packages/statamic-rad-pack-runway)

PHPackages © 2026

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