Search by

neamatrix / laravel-connex

torgodly

Laravel integration for the Connex (Ebtekar) direct carrier billing platform: anti-fraud OTP login, subscriptions, purchases and webhooks.

Package info

github.com/NeaMatrix/connex

pkg:composer/neamatrix/laravel-connex

Statistics

Installs: 3

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.1.0 2026-11-13 00:44 UTC

This package is not auto-updated.

Last update: 2026-11-13 16:45:55 UTC


README

Laravel integration for Connex, Ebtekar's direct carrier billing (DCB) platform. Subscribers sign in with their phone number and an SMS code, and pay from their mobile balance (Libyana, Almadar).

The package covers everything the Connex integration guide requires:

  • Anti-fraud OTP login. The DCBProtect script, phone step and OTP step, with resend, change number, rate limits and error messages.
  • The pages Connex requires. A login page and an account page (status, expiry, activate, cancel), in Arabic and English with RTL, linking to your terms, privacy and contact pages.
  • One login for every client. Mobile apps (webview) and web frontends (redirect or popup) get back a single-use code (OAuth-style, with PKCE) and exchange it for a Sanctum token to use on your API.
  • Every Connex API endpoint as a typed client, with typed results and typed exceptions.
  • Webhooks for subscribe, unsubscribe, reactivate and renewal. They are verified, idempotent and stored, and each fires a Laravel event.
  • Content access rules. connex.access middleware and $user->hasConnexAccess().
  • Testing. Connex::fake(), an in-memory Connex with assertions, plus a local demo app.
$details = Connex::subscriberDetails('0920920110');

$details->status;            // SubscriptionStatus::Active
$details->expiresAt;         // CarbonImmutable
$details->access()->allowsAccess();

Requirements

  • PHP 8.3+
  • Laravel 12 or 13
  • laravel/sanctum, to issue API tokens to apps and frontends

Installation

composer require neamatrix/laravel-connex
composer require laravel/sanctum   # if not installed
php artisan vendor:publish --tag=connex-config
php artisan vendor:publish --tag=connex-migrations
php artisan migrate

Add the credentials Ebtekar gave you to .env:

CONNEX_BASE_URL=https://connextst.ebtekarcloud.com/external-api
CONNEX_EMAIL=service@example.com
CONNEX_PASSWORD=secret
CONNEX_WEBHOOK_SECRET=a-long-random-string

Register your apps and frontends in config/connex.php (see Apps and frontends):

'clients' => [
    'mobile' => ['redirect_uris' => ['myapp://auth/connex'], 'pkce' => true],
    'web' => ['redirect_uris' => ['https://app.example.com/auth/connex/callback'], 'pkce' => true],
],

Add the traits to your user model:

use Laravel\Sanctum\HasApiTokens;
use NeaMatrix\Connex\Models\Concerns\HasConnexSubscription;

class User extends Authenticatable
{
    use HasApiTokens, HasConnexSubscription;
}

Check the connection:

php artisan connex:check --msisdn=0920920110

Clients open /connex/login?client=…. The subscriber's account page is at /connex/account.

Documentation

Guide What it covers
How Connex works The platform, the flows, and how the package maps onto them
Configuration Every config option
Apps and frontends Webview and frontend login, code → Sanctum token, account page in apps
Login page Customising and branding the pages per project, how users are created
Subscriptions and access The local mirror, access rules, middleware, activate and cancel
Webhooks Registering URLs with Connex, security, events
API client Every endpoint, results and exceptions
Testing Connex::fake() and the local demo
Architecture How the code is organised and where to extend it

Local demo

composer install
composer demo

This opens http://127.0.0.1:8000/demo, a sample frontend that signs in through the package and calls a Sanctum-protected API, all against an in-memory Connex. Any Libyan mobile number works, and the code is 1234.

Development

composer test      # Pest
composer analyse   # PHPStan level 8
composer format    # Pint
composer check     # all three

License

MIT