PHPackages                             alinmapay/alinmapay - 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. alinmapay/alinmapay

ActiveLibrary[Payment Processing](/categories/payments)

alinmapay/alinmapay
===================

Laravel package for Alinma Pay Payment Gateway integration

v1.0.1(1mo ago)11↓100%2MITPHPPHP ^8.1|^8.2|^8.3|^8.4

Since Apr 8Pushed 2w agoCompare

[ Source](https://github.com/YacoubAl-hardari/alinma-pay)[ Packagist](https://packagist.org/packages/alinmapay/alinmapay)[ RSS](/packages/alinmapay-alinmapay/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (4)Versions (3)Used By (0)

[![alt text](1.png)](1.png)

AlinmaPay Laravel Package
=========================

[](#alinmapay-laravel-package)

integration for Alinma Pay Payment Gateway in Laravel.

---

Features
--------

[](#features)

- Full integration with Hosted Payment Page
- SHA-256 signature generation &amp; verification
- AES response decryption
- Webhook support with signature verification
- Tokenization &amp; Recurring payments support
- OOP with Design Patterns (Builder, Factory, Strategy)
- Strict SOLID principles
- Type-safe with Enums &amp; DTOs

---

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

[](#installation)

```
composer require alinmapay/alinmapay
php artisan vendor:publish --provider="AlinmaPay\AlinmaPayServiceProvider" --tag=alinmapay-config --force
```

---

.env Example
------------

[](#env-example)

Add the following to your Laravel .env file:

```
# AlinmaPay Environment: sandbox or production
ALINMAPAY_ENV=sandbox

# Your merchant key (hex string from AlinmaPay dashboard)
ALINMAPAY_MERCHANT_KEY=your_merchant_key_hex

# Your terminal ID and password (from AlinmaPay dashboard)
ALINMAPAY_TERMINAL_ID=your_terminal_id
ALINMAPAY_TERMINAL_PASSWORD=your_terminal_password

# (Optional) Webhook timeout in seconds
ALINMAPAY_WEBHOOK_TIMEOUT=30
```

---

Quick Example (Get Hosted Payment URL Only)
-------------------------------------------

[](#quick-example-get-hosted-payment-url-only)

```
use AlinmaPay\Facades\AlinmaPay;
use AlinmaPay\Factories\PaymentRequestFactory;

$paymentUrl = AlinmaPay::createHostedPaymentPage(
    PaymentRequestFactory::purchase()
        ->amount(99.99)
        ->order('ORD_123', 'Product Purchase')
        ->customerEmail('user@example.com')
        ->billingAddress(country: 'SA')
        ->receiptUrl(route('payment.callback'))
        ->build()
);

return redirect()->away($paymentUrl);
```

---

Advanced Usage
--------------

[](#advanced-usage)

### 1. Create Hosted Payment Page (Controller Example)

[](#1-create-hosted-payment-page-controller-example)

```
public function createPaymentPage(Request $request)
{
    $validated = $request->validate([
        'order_id' => 'required|string|unique:orders,id',
        'amount' => 'required|numeric|min:0.01',
        'email' => 'required|email',
        'description' => 'nullable|string|max:255',
    ]);

    $paymentRequest = PaymentRequestFactory::purchase()
        ->amount($validated['amount'])
        ->order($validated['order_id'], $validated['description'] ?? 'Purchase')
        ->customerEmail($validated['email'])
        ->billingAddress(city: 'Riyadh', country: 'SA')
        ->receiptUrl(route('payment.callback'))
        ->userData([
            'user_id' => auth()->id(),
            'order_type' => 'online',
        ])
        ->build();

    $paymentUrl = AlinmaPay::createHostedPaymentPage($paymentRequest);
    return redirect()->away($paymentUrl);
}
```

### 2. Handle Payment Callback (Receipt URL) and Check Payment Status

[](#2-handle-payment-callback-receipt-url-and-check-payment-status)

```
use AlinmaPay\DTOs\PaymentResponseDTO;

public function handle(Request $request)
{
    $encryptedData = $request->input('data');
    $merchantKey = config('alinmapay.merchant_key');
    $decrypted = app(ResponseEncryptionService::class)->decryptResponse($encryptedData, $merchantKey);
    $response = new PaymentResponseDTO(
        $decrypted['transactionId'] ?? '',
        $decrypted['orderId'] ?? '',
        $decrypted['status'] ?? ($decrypted['result'] ?? ''),
        $decrypted['responseCode'] ?? '',
        $decrypted['message'] ?? '',
        isset($decrypted['amount']) ? (float)$decrypted['amount'] : 0.0,
        $decrypted['currency'] ?? '',
        $decrypted['paymentId'] ?? null,
        $decrypted['signature'] ?? null,
        $decrypted // rawData
    );
    // To get the full raw response data (all fields returned by the gateway):
    $allResponseData = $response->getResultData();
    // Example: Log::info('Full payment response', $allResponseData);

    if ($response->isSuccess()) {
        // Payment completed successfully
        // Example: update order status in your database
        // Order::where('id', $response->orderId)->update(['status' => 'paid']);
    } elseif ($response->isFailed()) {
        // Payment failed
        $errorMessage = $response->message ?? $response->responseCode ?? 'Payment failed';
        // Example: log or show error
        // Log::error('Payment failed', ['error' => $errorMessage]);
    } elseif ($response->isCancelled()) {
        // Payment was cancelled by the user or system
        // Example: update order status or notify user
        // Order::where('id', $response->orderId)->update(['status' => 'cancelled']);
    } elseif ($response->isRefunded()) {
        // Payment was refunded
        // Example: update order status or notify user
        // Order::where('id', $response->orderId)->update(['status' => 'refunded']);
    } else {
        // Unknown status, handle as needed
        // Log::warning('Unknown payment status', $decrypted);
    }

}
```

### 3. Webhook Handling

[](#3-webhook-handling)

```
public function handle(Request $request)
{
    $payload = $request->all();
    // Verify signature if needed
    app(WebhookService::class)->handleWebhook($payload);
    return response()->json(['status' => 'received'], 200);
}
```

### 4. Recurring Payments

[](#4-recurring-payments)

```
$paymentRequest = PaymentRequestFactory::purchase()
    ->amount(100.00)
    ->order('SUB_12345', 'Monthly Subscription')
    ->customerEmail('customer@example.com')
    ->billingAddress(country: 'SA')
    ->withRecurring([
        'frequency' => 'M',
        'startDate' => '01/02/2026',
        'subscriptionAmount' => '100.00',
        'subscriptionType' => 's',
        'paymentDays' => '01',
        'paymentType' => 'R',
        'noOfSubscriptionPayments' => '12',
    ])
    ->build();
$paymentUrl = AlinmaPay::createHostedPaymentPage($paymentRequest);
```

### 5. Tokenization

[](#5-tokenization)

```
$tokenRequest = PaymentRequestFactory::tokenization()
    ->amount(1.00)
    ->order('TOKEN_' . uniqid(), 'Card Tokenization')
    ->customerEmail('customer@example.com')
    ->billingAddress(country: 'SA')
    ->withTokenization(cardToken: null, operation: 'A')
    ->receiptUrl(route('tokenization.callback'))
    ->build();
$paymentUrl = AlinmaPay::createHostedPaymentPage($tokenRequest);
```

---

Technical Notes
---------------

[](#technical-notes)

- All requests are POST to the official endpoint.
- Signature is generated using SHA-256 as per documentation.
- Final response is AES-encrypted and must be decrypted using the merchant key.
- All code is OOP and SOLID-compliant.
- All errors are handled via clear Exceptions.

### Signature Verification

[](#signature-verification)

```
$signature = app(SignatureService::class)->generateRequestSignature(...);
```

### Decrypting Response

[](#decrypting-response)

```
$decrypted = app(ResponseEncryptionService::class)->decryptResponse($encryptedData, $merchantKey);
```

---

Support
-------

[](#support)

For technical inquiries:

###  Health Score

42

—

FairBetter than 90% of packages

Maintenance95

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~0 days

Total

2

Last Release

31d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/1fb3960cf6e949bc5401902a09bf597da5bf4aeaf53c382bb55b1843769c0347?d=identicon)[Yacoub\_Al-haidari](/maintainers/Yacoub_Al-haidari)

---

Top Contributors

[![YacoubAl-hardari](https://avatars.githubusercontent.com/u/94101869?v=4)](https://github.com/YacoubAl-hardari "YacoubAl-hardari (8 commits)")

---

Tags

alinmapayalinmapay-laravellaravel-alinmapaypaypaymentpayment-gatewaypayment-integration

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/alinmapay-alinmapay/health.svg)

```
[![Health](https://phpackages.com/badges/alinmapay-alinmapay/health.svg)](https://phpackages.com/packages/alinmapay-alinmapay)
```

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[musahmusah/laravel-multipayment-gateways

A Laravel Package that makes implementation of multiple payment Gateways endpoints and webhooks seamless

852.2k1](/packages/musahmusah-laravel-multipayment-gateways)[karson/mpesa-php-sdk

172.2k](/packages/karson-mpesa-php-sdk)[henryejemuta/laravel-monnify

A laravel package to seamlessly integrate monnify api within your laravel application

132.1k](/packages/henryejemuta-laravel-monnify)

PHPackages © 2026

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