cofa / neoleap-integration-package
This package helps you to integrate with Neoleap payment getaway
Package info
github.com/Cofa12/Neoleap-integration-package
pkg:composer/cofa/neoleap-integration-package
Requires
- phpunit/phpunit: ^13.1
Requires (Dev)
- vimeo/psalm: ^6.16
README
A PHP/Laravel package to seamlessly integrate the Neoleap Payment Gateway into your application.
Features
- Secure Encryption: Built-in AES-128-CBC encryption for transaction data.
- DTO Support: Structured
TranDataWrapperfor easy request management. - Laravel Ready: Easy configuration and integration.
- Comprehensive Testing: Includes unit and feature tests.
- Response Decryption: Easily decrypt and parse gateway responses.
Installation
You can install the package via composer:
composer require cofa/neoleap-integration-package
Configuration
The package uses a configuration file to manage your Neoleap credentials. You can create a config/neoleap.php file in your project root (or it will be automatically published if using Laravel).
return [ 'password' => env('NEOLEAP_PASSWORD', ''), 'tranportal_id' => env('NEOLEAP_TRANPORTAL_ID', ''), 'merchant_id' => env('NEOLEAP_MERCHANT_ID', ''), 'encryption_key' => env('NEOLEAP_ENCRYPTION_KEY', 'DCB04EAA4019E367F005909DA87B031A'), 'encryption_iv' => env('NEOLEAP_ENCRYPTION_IV', 'PGKEYENCDECIVSPC'), 'neoleap_url' => env('NEOLEAP_URL', 'https://securepayments.neoleap.com.sa/pg/payment/hosted.htm'), 'response_url' => env('NEOLEAP_RESPONSE_URL', ''), 'error_url' => env('NEOLEAP_ERROR_URL', ''), ];
Usage
Simple Checkout
The Checkout service handles the complexity of encrypting data and posting to Neoleap.
use Cofa\NeoleapIntegrationPackage\Services\Checkout; $checkout = new Checkout(); $response = $checkout->checkout(); // The response will typically contain the HTML form or redirect response from Neoleap echo $response;
Manual Request Building
You can use the TranDataWrapper to manually build and encrypt your request.
use Cofa\NeoleapIntegrationPackage\DTOs\TranDataWrapper; $dataWrapper = new TranDataWrapper( amt: 100, // Amount action: 1, // 1 for Purchase currencyCode: 682, // SAR trackId: 'order_123' // Unique track ID ); // Get encrypted string for 'trandata' field $encryptedTrandata = $dataWrapper->returnEncryptedTrandata();
Decrypting Response
When Neoleap redirects back to your responseURL, you can decrypt the transaction data:
$dataWrapper = new TranDataWrapper(amt: 0); // Config is loaded automatically $decryptedJson = $dataWrapper->decryptResponse($_POST['trandata']); $responseData = json_decode($decryptedJson, true);
Testing
Run the test suite using PHPUnit:
vendor/bin/phpunit
Security
If you discover any security-related issues, please email 112869567+Cofa12@users.noreply.github.com instead of using the issue tracker.
License
The MIT License (MIT). Please see License File for more information.