herepay / herepay-php-sdk
Herepay payment gateway PHP SDK.
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:sdk
Requires
- php: ^7.4|^8.0|^8.1|^8.2
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/container: ^11
Requires (Dev)
- illuminate/support: ^7.0|^8.0|^9.0|^10.0|^11.0
- phpunit/phpunit: ^11.0
- psr/simple-cache: ^2.0
This package is not auto-updated.
Last update: 2025-06-15 18:58:05 UTC
README
A PHP SDK for integrating with the Herepay payment gateway. This package provides a simple and efficient way to interact with the Herepay API for managing transactions, retrieving payment channels, and more.
Installation
Install the package via Composer:
composer require Herepay/herepay-php-sdk
If using Laravel, publish the configuration file:
php artisan vendor:publish --provider="HerepaySDK\HerepayServiceProvider" --tag=config
Configuration
Ensure you add the following environment variables to your .env
file:
HEREPAY_SANDBOX=true HEREPAY_SECRET_KEY=your_secret_key HEREPAY_API_KEY=your_api_key HEREPAY_PRIVATE_KEY=your_private_key
Or you can manually configure the SDK by passing the configuration array when initializing the HerepayService
.
Usage
Initialize the SDK
use HerepaySDK\HerepayService; $config = [ 'sandbox' => true, // Use false for production 'secret_key' => 'your_secret_key', 'api_key' => 'your_api_key', 'private_key' => 'your_private_key', ]; $herepay = new HerepayService($config);
Get Payment Channels
Retrieve available payment channels:
$paymentChannels = $herepay->getPaymentChannels(); echo $paymentChannels;
Initiate transaction
Initiate transaction, response will redirect to Acquiring Bank
$transactionData = [ 'payment_code' => 'REF-123', 'created_at' => date('Y-m-d H:i:s'), 'amount' => 100, 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'phone' => '0123456789', 'description' => 'Test Transaction', 'bank_prefix' => 'TEST0021', 'payment_method' => 'Online Banking', ]; $transactionData['checksum'] = $herepay->generateChecksum($transactionData); $response = $herepay->initiate($transactionData); header($response);
Get Transaction Details
Retrieve the details of a transaction:
$referenceCode = 'HP-INVAPI-XXXXXXXXXX'; $transactionDetails = $herepay->getTransactionDetails($referenceCode); echo $transactionDetails;
Get Latest Transaction
Retrieve the latest transaction:
$transactions = $herepay->getTransactions(); echo $transactions;
Generate Checksum
Generate a checksum for data validation:
$transactionData = [ 'payment_code' => 'REF-123', 'created_at' => date('Y-m-d H:i:s'), 'amount' => 100, 'name' => 'John Doe', 'email' => 'john.doe@example.com', 'phone' => '0123456789', 'description' => 'Test Transaction', 'bank_prefix' => 'TEST0021', 'payment_method' => 'Online Banking', ]; $checksum = $herepay->generateChecksum($transactionData); echo $checksum;
Testing
Run the tests using PHPUnit:
vendor/bin/phpunit --testdox tests
Ensure that the .env.testing
file is properly set up with sandbox credentials.
Contributing
Contributions are welcome! Please fork this repository, make your changes, and submit a pull request.
License
This package is open-sourced software licensed under the MIT license.