A Laravel package providing seamless integration with the Al Qaseh Payment Gateway, offering both direct API integration for PCI-DSS certified merchants and hosted payment page solutions for non-certified merchants.
- π³ Full payment gateway integration for Laravel applications
- π Supports both PCI-DSS certified and non-certified merchant flows
- π¦ Comprehensive API coverage including:
- Payment creation & processing
- Payment status tracking
- History retrieval & CSV export
- Payment retry & revocation
- Detailed payment context inspection
- π‘οΈ Built-in validation and error handling
- π§ͺ Sandbox mode with test credentials
- π Automatic configuration management
- π Support for all transaction types (Retail, Authorization, Reversal, CompleteSales)
For complete API documentation, see the Official Al Qaseh Documentation.
composer require osa-eg/laravel-alqaseh
Publish the configuration file:
php artisan vendor:publish --provider="Osama\AlQaseh\AlQasehServiceProvider" --tag="config"
Configuration options (config/alqaseh.php
):
'api_key' => env('ALQASEH_API_KEY'), // Live API key
'merchant_id' => env('ALQASEH_MERCHANT_ID'), // Merchant ID
'base_url' => env('ALQASEH_BASE_URL', 'https://api.alqaseh.com/v1'),
'sandbox' => env('ALQASEH_SANDBOX', true), // Enable test mode
// Sandbox credentials (automatically used when sandbox=true)
'sandbox_credentials' => [
'api_key' => '1X6Bvq65kpx1Yes5fYA5mbm8ixiexONo',
'merchant_id' => 'public_test',
'base_url' => 'https://api-test.alqaseh.com/v1',
],
Add to your .env
:
ALQASEH_API_KEY=your-live-api-key
ALQASEH_MERCHANT_ID=your-merchant-id
ALQASEH_SANDBOX=true
use Osama\AlQaseh\Facades\AlQaseh;
// Configuration is automatically loaded from .env
// Sandbox mode is enabled by default
Create Payment (API Reference)
try {
$response = AlQaseh::createPayment(
amount: 100.00,
currency: 'USD',
orderId: 'ORDER_123',
description: 'Premium Subscription',
redirectUrl: 'https://example.com/callback',
transactionType: 'Retail',
email: '[email protected]',
country: 'US',
webhookUrl: 'https://example.com/webhooks/payment'
);
if ($response->isSuccessful()) {
$paymentUrl = $response->getPaymentUrl();
// Redirect to payment URL for non-PCI-DSS merchants
return redirect()->away($paymentUrl);
}
} catch (AlQasehException $e) {
// Handle API errors
} catch (InvalidArgumentException $e) {
// Handle validation errors
}
Get Payment History (API Reference)
$history = AlQaseh::getPaymentHistory(
filters: [
'from' => now()->subWeek(),
'to' => now(),
'payment_status' => 'succeeded'
],
limit: 50,
orderBy: 'desc'
);
$payments = $history->getData()['payments'];
Download Payment History (API Reference)
$csvData = AlQaseh::downloadPaymentHistory([
'transaction_type' => 'Retail',
'from' => '2024-01-01',
'order_by' => 'asc'
]);
Storage::put('payments.csv', $csvData);
Get Payment Information (API Reference)
$paymentInfo = AlQaseh::getPaymentInfo('payment-id');
$status = $paymentInfo->getData()['status'];
// Get by payment token
$tokenInfo = AlQaseh::getPaymentInfoByToken('payment-token');
Direct Payment Processing (PCI-DSS Certified Only) (API Reference)
try {
$result = AlQaseh::processPayment(
token: 'payment-token',
cardNumber: '4111111111111111',
cvv: '123',
expiryMonth: '12',
expiryYear: '2026'
);
if ($result->isSuccessful()) {
$transactionId = $result->getTransactionId();
}
} catch (AlQasehException $e) {
// Handle processing errors
}
Retry Failed Payment (API Reference)
AlQaseh::retryPayment(
paymentId: 'failed-payment-id',
details: 'Retry after system error'
);
Revoke Payment (API Reference)
AlQaseh::revokePayment(
paymentId: 'pending-payment-id',
details: 'Customer cancellation request'
);
The package includes automatic validation for all requests using dedicated validators:
CreatePaymentValidator
: Validates payment creation parametersPaymentHistoryValidator
: Ensures valid history filtersPaymentInfoValidator
: Validates payment ID formatsPaymentInfoByTokenValidator
: Validates payment Token formatsProcessPaymentValidator
: Validates process request parametersRetryPaymentValidator
: Validates retry request parametersRevokePaymentValidator
: Ensures proper revocation requests
Example validation error handling:
try {
// API operation
} catch (InvalidArgumentException $e) {
return response()->json([
'error' => $e->getMessage()
], 400);
}
The PaymentResponse
object provides these methods:
$response->isSuccessful(); // Check if request succeeded
$response->getPaymentUrl(); // Get hosted payment page URL
$response->getTransactionId(); // Retrieve transaction ID
$response->getErrorMessage(); // Get error description
$response->getErrorCode(); // Get API error code
$response->getData(); // Get full response payload
This package supports:
- PCI-DSS compliant integrations for certified merchants
- Secure hosted payment pages for non-certified merchants
- End-to-end encryption
- Sandbox testing environment
- Automatic credential management
- Built-in input validation
The MIT License (MIT). Please see License File for more information.