lahza / payment-gateway
A robust Laravel payment gateway package developed by Palestinian developer Khalil Khasseb
Installs: 7
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/lahza/payment-gateway
Requires
- php: ^8.0
- ext-json: *
- guzzlehttp/guzzle: ^7.0
- illuminate/support: ^9.0|^10.0
README
A Laravel package for seamless integration with the Lahza Payment Gateway. Process payments, handle webhooks, and manage transactions with ease.
Author
Khalil Khasseb
π Palestine - Aroura
βοΈ khalil.khasseb@proton.me
π» GitHub Profile
Features (Updated)
- π° Automatic currency conversion (USD/ILS/JOD)
- π Conditional webhook handling
- π§© Data Transfer Objects (DTOs) for API responses
- π¦ Improved validation error messages
Configuration (Updated)
Add to your .env:
LAHZA_INLINE_CALLBACK=false LAHZA_CALLBACK_URL= LAHZA_DEFAULT_CURRENCY=USD ## Features - π³ Create payment intents - π Handle payment confirmations - β©οΈ Process refunds - πΈοΈ Webhook verification - π‘οΈ Robust error handling - βοΈ Configurable settings - π§ͺ Fake mode for testing ## Installation Install via Composer: ```bash composer require lahza/payment-gateway
Publish config file:
php artisan vendor:publish --provider="Lahza\PaymentGateway\LahzaServiceProvider" --tag="lahza-config"
Configuration
Add to your .env file:
LAHZA_API_KEY=your_api_key LAHZA_BASE_URL=https://api.lahza.io/v1/ LAHZA_WEBHOOK_SECRET=your_webhook_secret LAHZA_TIMEOUT=15 LAHZA_RETRIES=3 LAHZA_CURRENCIES=USD,EUR,GBP
Config Options (config/lahza.php)
| Key | Type | Description |
|---|---|---|
| api_key | string | Your Lahza API key |
| base_url | string | API base URL |
| timeout | int | Request timeout in seconds |
| retries | int | Number of request retries |
| retry_delay | int | Delay between retries in milliseconds |
| webhook.secret | string | Webhook verification secret |
| webhook.middleware | array | Middleware for webhook routes |
| currencies | array | Supported currencies |
Usage
Create Payment Intent
use Lahza\Facades\Lahza; try { use Lahza\Facades\Lahza; $transaction = Lahza::initializeTransaction([ 'email' => 'customer@example.com', 'amount' => 100.50, // Automatically converted to cents 'currency' => 'USD' ]); return redirect()->away($transaction->authorizationUrl); } catch (\Lahza\PaymentGateway\Exceptions\PaymentException $e) { // Handle error }
Confirm Payment
$verified = Lahza::verifyTransaction('TXN_12345'); echo $verified->amount; // Returns decimal value
Handle Webhooks
// Get supported currencies $currencies = config('lahza.currencies'); // Get default currency $default = Lahza::getDefaultCurrency();
Handle Webhooks
Add to routes/web.php:
Route::post('/lahza/webhook', function (Request $request) { // Handle webhook })->middleware('lahza.webhook');
Webhook config
'webhook' => [ 'enabled' => true, 'secret' => env('LAHZA_WEBHOOK_SECRET'), 'middleware' => ['api'] ]
Error Handling
try { $transaction = Lahza::initializeTransaction(...); } catch (\Lahza\PaymentGateway\Exceptions\PaymentValidationException $e) { foreach ($e->getErrors() as $field => $messages) { // Handle validation errors } } catch (\Lahza\PaymentGateway\Exceptions\PaymentException $e) { logger()->error('Payment failed: ' . $e->getMessage(), [ 'context' => $e->getContext() ]); }
Sample error response:
{
"error": "validation_error",
"message": "Validation failed for 2 fields",
"error_code": 422,
"documentation": "https://api-docs.lahza.io/errors/422",
"errors": {
"amount": ["Must be at least 0.5"],
"currency": ["Invalid currency"]
}
}
Testing
Enable fake mode:
Lahza::fake(); // Mock specific endpoints Lahza::fake([ '/transaction/initialize' => [ 'status' => true, 'data' => [ 'authorization_url' => 'https://checkout.lahza.io/fake', 'reference' => 'TEST_123' ] ] ]);****
TODO: Future Enhancements
- Add support for recurring payments
- Implement payment method management
- Add currency conversion utilities
- Support 3D Secure payments
- Create admin dashboard integration
- Add more test coverage
- Implement rate limiting
- Add payment dispute handling
- Support multiple API versions
- Add PCI-compliant card storage
- Develop mobile SDK integration
- Create webhook event factory
- Add payment analytics
- Support marketplace split payments
- Implement payment retry logic
Documentation
Full API documentation available at Lahza API Docs
Contributing
- Fork the project
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add some amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
Security
If you discover any security issues, please email:
π khalil.khasseb@proton.me
instead of using the issue tracker.
License
The MIT License (MIT). See LICENSE for more information.