PHPackages                             cofa/neoleap-integration-package - 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. [Payment Processing](/categories/payments)
4. /
5. cofa/neoleap-integration-package

ActiveLibrary[Payment Processing](/categories/payments)

cofa/neoleap-integration-package
================================

This package helps you to integrate with Neoleap payment getaway

v1.6(2mo ago)0151MITPHPCI passing

Since May 6Pushed 2mo agoCompare

[ Source](https://github.com/Cofa12/Neoleap-integration-package)[ Packagist](https://packagist.org/packages/cofa/neoleap-integration-package)[ RSS](/packages/cofa-neoleap-integration-package/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependencies (2)Versions (8)Used By (0)

Neoleap Integration Package
===========================

[](#neoleap-integration-package)

[![Latest Version on Packagist](https://camo.githubusercontent.com/4a609d876147afd879450fdf55a37728ee783843ffc2b56cd8f6c9c74857a391/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636f66612f6e656f6c6561702d696e746567726174696f6e2d7061636b6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cofa/neoleap-integration-package)[![Total Downloads](https://camo.githubusercontent.com/1c601b13ca7274966a4f443d77f69c661fed2ca6bededc0c6c8cc084fd23299d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636f66612f6e656f6c6561702d696e746567726174696f6e2d7061636b6167652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cofa/neoleap-integration-package)[![GitHub Tests Action Status](https://camo.githubusercontent.com/772da11325c97285df11eb7586f0d4ebabda769bc76f20352662954c81d39789/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636f666131322f4e656f6c6561702d696e746567726174696f6e2d7061636b6167652f746573742e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/cofa12/Neoleap-integration-package/actions)

A PHP/Laravel package to seamlessly integrate the [Neoleap Payment Gateway](https://securepayments.neoleap.com.sa) into your application.

Features
--------

[](#features)

- **Hosted Checkout** — redirect customers to the Neoleap-hosted payment page
- **Faster Checkout** — one-click checkout for returning customers via `custid`
- **Iframe Checkout** — embed the Neoleap payment form inside your own page
- **Card on File** — register, charge, and delete saved cards
- **Wallet Payment** — charge via mobile wallet (STC Pay etc.)
- **Callback Parsing** — decrypt and parse Neoleap's encrypted callback response
- **AES-256-CBC Encryption** — built-in PKCS5-padded encryption matching gateway spec
- **Laravel &amp; plain PHP** — works with or without the Laravel framework

---

Requirements
------------

[](#requirements)

- PHP 8.1+
- `ext-openssl`
- `ext-curl`

---

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

[](#installation)

```
composer require cofa/neoleap-integration-package
```

### Laravel

[](#laravel)

The service provider is auto-discovered. Publish the config file:

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

---

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

[](#configuration)

Create or publish `config/neoleap.php`:

```
return [
    'password'             => env('NEOLEAP_PASSWORD', ''),
    'tranportal_id'        => env('NEOLEAP_TRANPORTAL_ID', ''),
    'encryption_key'       => env('NEOLEAP_ENCRYPTION_KEY', ''),   // 32-byte raw key
    'encryption_iv'        => env('NEOLEAP_ENCRYPTION_IV', ''),    // 16-byte IV
    'neoleap_url'          => env('NEOLEAP_URL', 'https://securepayments.neoleap.com.sa/pg/payment/hosted.htm'),
    'neoleap_merchant_url' => env('NEOLEAP_MERCHANT_URL', 'https://securepayments.neoleap.com.sa/pg/payment/tranportal.htm'),
    'response_url'         => env('NEOLEAP_RESPONSE_URL', ''),
    'error_url'            => env('NEOLEAP_ERROR_URL', ''),
];
```

Add the corresponding variables to your `.env`:

```
NEOLEAP_PASSWORD=your_password
NEOLEAP_TRANPORTAL_ID=your_tranportal_id
NEOLEAP_ENCRYPTION_KEY=your_32_byte_key
NEOLEAP_ENCRYPTION_IV=your_16_byte_iv
NEOLEAP_RESPONSE_URL=https://yourapp.com/neoleap/callback/success
NEOLEAP_ERROR_URL=https://yourapp.com/neoleap/callback/error
```

---

Usage
-----

[](#usage)

### 1. Hosted Checkout

[](#1-hosted-checkout)

Redirect the customer to the Neoleap-hosted payment page.

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\TranDataWrapper;

$checkout = new Checkout();

$wrapper = new TranDataWrapper(
    amt:     150,                 // amount in SAR (integer)
    action:  1,                   // 1=purchase, 2=auth, 3=refund, 4=void
    trackId: 'order_' . time(),  // optional — defaults to time()
    langid:  'ar',                // 'ar' or 'en'
);

$response = $checkout->checkout($wrapper, customerIp: '203.0.113.1');
// $response[0]['status']      — '1' on success
// $response[0]['result']      — 'paymentId:redirectUrl'

[$paymentId, $redirectUrl] = explode(':', $response[0]['result'], 2);
header('Location: ' . $redirectUrl);
exit;
```

#### TranDataWrapper parameters

[](#trandatawrapper-parameters)

ParameterTypeDefaultDescription`amt``int`—Amount in SAR`action``int``1`1=purchase, 2=auth, 3=refund, 4=void`currencyCode``int``682`682 = Saudi Riyal`trackId``string``time()`Unique order reference`responseURL``string`from configSuccess callback URL`errorURL``string`from configError callback URL`langid``string``'ar'`Payment page language (`ar` / `en`)`udf1`–`udf5``string``''`User-defined fields (passed through)> `tranportal_id` and `password` are always loaded from config — no need to pass them.

---

### 2. Card on File — Register

[](#2-card-on-file--register)

Save a card for future charges without storing card details yourself.

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\CardOnFileRegistrationData;

$checkout = new Checkout();

$dto = new CardOnFileRegistrationData(
    cardNo:   '4012001037141112',
    expMonth: '05',
    expYear:  '2027',
);

$response = $checkout->registerCard($dto, customerIp: '203.0.113.1');
// $response[0]['maskedCardNo']      — masked PAN e.g. 401200******1112
// $response[0]['cardOnFileToken']   — token to use for future charges
```

#### CardOnFileRegistrationData parameters

[](#cardonfileregistrationdata-parameters)

ParameterTypeRequiredDescription`cardNo``string`yesFull card number`expMonth``string`yesExpiry month (2 digits)`expYear``string`yesExpiry year (4 digits)`cardOnFileToken``string`noExisting token (for re-registration)---

### 3. Card on File — Pay with Saved Card

[](#3-card-on-file--pay-with-saved-card)

Charge a previously registered card using its token.

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\CardOnFilePaymentData;

$checkout = new Checkout();

$dto = new CardOnFilePaymentData(
    amt:             150,
    cardOnFileToken: '202613103841966',
    maskedCardNo:    '401200******1112',
    cvv2:            '123',
    member:          'John Doe',
    cardType:        'C',           // 'C' = credit, 'D' = debit
    trackId:         'order_' . time(),  // optional — defaults to time()
);

$response = $checkout->payWithSavedCard($dto, customerIp: '203.0.113.1');
// $response[0]['status'] — '1' on success
// $response[0]['result'] — result code e.g. 'CAPTURED'
```

#### CardOnFilePaymentData parameters

[](#cardonfilepaymentdata-parameters)

ParameterTypeDefaultDescription`amt``float`—Amount in SAR`cardOnFileToken``string`—Token from registration`maskedCardNo``string`—Masked PAN returned at registration`cvv2``string`—Card CVV2`member``string`—Cardholder name`cardType``string`—`'C'` credit / `'D'` debit`action``int``1`1=purchase, 2=auth`currencyCode``int``682`682 = Saudi Riyal`trackId``string``time()`Unique order reference`udf1`–`udf5``string``''`User-defined fields---

### 4. Card on File — Delete Saved Card

[](#4-card-on-file--delete-saved-card)

Remove a previously registered card token from the gateway.

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\CardOnFileDeletionData;

$checkout = new Checkout();

$dto = new CardOnFileDeletionData(
    cardOnFileToken: '202613103841966',
);

$response = $checkout->deleteCard($dto, customerIp: '203.0.113.1');
// $response[0]['status'] — '1' on success
```

#### CardOnFileDeletionData parameters

[](#cardonfiledeletiondata-parameters)

ParameterTypeRequiredDescription`cardOnFileToken``string`yesToken to delete---

### 5. Wallet Payment

[](#5-wallet-payment)

Charge a customer via mobile wallet (e.g. STC Pay).

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\WalletPaymentData;

$checkout = new Checkout();

$dto = new WalletPaymentData(
    amt:          150,
    mobileNumber: '512345678',          // 9 digits, no country code
    trackId:      'order_' . time(),    // optional — defaults to time()
);

$response = $checkout->payWithWallet($dto, customerIp: '203.0.113.1');
// $response[0]['status'] — '1' on success
// $response[0]['result'] — 'paymentId:redirectUrl'
```

#### WalletPaymentData parameters

[](#walletpaymentdata-parameters)

ParameterTypeDefaultDescription`amt``int`—Amount in SAR`mobileNumber``string`—9-digit mobile number (no prefix)`action``int``1`1=purchase`currencyCode``int``682`682 = Saudi Riyal`trackId``string``time()`Unique order reference`udf1`–`udf5``string``''`User-defined fields> **Validation:** `mobileNumber` must be exactly 9 digits — an `InvalidArgumentException` is thrown otherwise.

---

### 6. Faster Checkout

[](#6-faster-checkout)

One-click checkout for returning customers identified by a `custid`. Neoleap uses the stored customer profile to pre-fill card details.

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\FasterCheckoutData;

$checkout = new Checkout();

$dto = new FasterCheckoutData(
    amt:    150,
    custid: 'customer_42',           // required — your unique customer identifier
    langid: 'ar',
    trackId: 'order_' . time(),      // optional — defaults to time()
);

$response = $checkout->checkoutFaster($dto, customerIp: '203.0.113.1');
// $response[0]['status']      — '1' on success
// $response[0]['result']      — 'paymentId:redirectUrl'
```

#### FasterCheckoutData parameters

[](#fastercheckoutdata-parameters)

ParameterTypeDefaultDescription`amt``float`—Amount in SAR`custid``string`—**Required.** Your unique customer ID`action``int``1`1=purchase, 2=auth`currencyCode``int``682`682 = Saudi Riyal`trackId``string``time()`Unique order reference`responseURL``string`from configOverride success callback URL`errorURL``string`from configOverride error callback URL`langid``string``'ar'`Payment page language (`ar` / `en`)`custCardHolderName``string``null`Optional cardholder name pre-fill`custMobileNumber``string``null`Optional mobile number pre-fill`custEmailId``string``null`Optional email pre-fill`udf1`–`udf5``string``''`User-defined fields> **Validation:** `custid` must not be empty — an `InvalidArgumentException` is thrown otherwise.

---

### 7. Iframe Checkout

[](#7-iframe-checkout)

Embed the Neoleap payment form inside your own page using an iframe. The gateway forces `udf3` to `'iframe'` internally — do not pass it yourself.

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;
use Cofa\NeoleapIntegrationPackage\DTOs\IframeCheckoutData;

$checkout = new Checkout();

$dto = new IframeCheckoutData(
    amt:    150,
    langid: 'ar',
    trackId: 'order_' . time(),  // optional — defaults to time()
);

$response = $checkout->checkoutIframe($dto, customerIp: '203.0.113.1');
// $response[0]['status']      — '1' on success
// $response[0]['result']      — 'paymentId:redirectUrl'
```

#### IframeCheckoutData parameters

[](#iframecheckoutdata-parameters)

ParameterTypeDefaultDescription`amt``float`—Amount in SAR`action``int``1`1=purchase, 2=auth`currencyCode``int``682`682 = Saudi Riyal`trackId``string``time()`Unique order reference`responseURL``string`from configOverride success callback URL`errorURL``string`from configOverride error callback URL`langid``string``'ar'`Payment page language (`ar` / `en`)`custid``string``null`Optional customer ID`custCardHolderName``string``null`Optional cardholder name pre-fill`custMobileNumber``string``null`Optional mobile number pre-fill`custEmailId``string``null`Optional email pre-fill`udf1`, `udf2`, `udf4`, `udf5``string``''`User-defined fields (`udf3` is reserved)> **Note:** `udf3` is always set to `'iframe'` by the gateway spec — any value you pass is ignored.

---

### 8. Parsing the Callback Response

[](#8-parsing-the-callback-response)

Neoleap posts an encrypted `trandata` field to your `responseURL`. Use `parseCallbackResponse` to decrypt and extract the result:

```
use Cofa\NeoleapIntegrationPackage\Services\Checkout;

$checkout = new Checkout();

$result = $checkout->parseCallbackResponse($_POST['trandata']);

if ($result['success']) {
    // Payment captured
    $trackId   = $result['trackId'];   // your original order reference
    $auth      = $result['auth'];      // authorization code
    $ref       = $result['ref'];       // bank reference
    $paymentId = $result['paymentId'];
    $amt       = $result['amt'];
} else {
    // Payment failed
    $rawResult = $result['result'];    // raw result code from gateway
}
```

#### parseCallbackResponse return keys

[](#parsecallbackresponse-return-keys)

KeyDescription`success``true` if result is `CAPTURED``result`Raw result string from gateway`auth`Authorization code`ref`Bank reference number`trackId`Your original order `trackId``paymentId`Neoleap payment ID`amt`Charged amount`raw`Full decoded response array---

Testing
-------

[](#testing)

```
vendor/bin/phpunit
```

Live integration tests (tests that hit the real gateway) are automatically skipped when `tranportal_id` is empty in `config/neoleap.php`.

---

Security
--------

[](#security)

Never commit real credentials to version control. Always use environment variables and keep `config/neoleap.php` out of your repository (add it to `.gitignore`).

If you discover a security vulnerability, please email `112869567+Cofa12@users.noreply.github.com` instead of opening a public issue.

---

License
-------

[](#license)

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

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance86

Actively maintained with recent releases

Popularity7

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity39

Early-stage or recently created project

 Bus Factor1

Top contributor holds 51.4% 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 ~2 days

Total

7

Last Release

68d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5548684?v=4)[Cofa](/maintainers/Cofa)[@cofa](https://github.com/cofa)

---

Top Contributors

[![Cofa12](https://avatars.githubusercontent.com/u/112869567?v=4)](https://github.com/Cofa12 "Cofa12 (19 commits)")[![ahmedessawy10](https://avatars.githubusercontent.com/u/60954792?v=4)](https://github.com/ahmedessawy10 "ahmedessawy10 (18 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/cofa-neoleap-integration-package/health.svg)

```
[![Health](https://phpackages.com/badges/cofa-neoleap-integration-package/health.svg)](https://phpackages.com/packages/cofa-neoleap-integration-package)
```

###  Alternatives

[pagseguro/php

Biblioteca de integração com o PagSeguro

23260.3k6](/packages/pagseguro-php)[dinkbit/conekta-cashier

Dinkbit Cashier nos da una interface para cobrar subscripciones con Conketa en Laravel.

365.4k](/packages/dinkbit-conekta-cashier)[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.4k](/packages/msilabs-bkash)[binkode/laravel-paystack

A description for laravel-paystack.

112.1k](/packages/binkode-laravel-paystack)

PHPackages © 2026

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