PHPackages                             alaa-elsaid/arb - 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. alaa-elsaid/arb

ActiveLibrary[Payment Processing](/categories/payments)

alaa-elsaid/arb
===============

Laravel API for Al Rajhi Bank's payment gateway (ARB)

v1.0.0(1y ago)017MITPHPPHP ^8.0

Since Aug 16Pushed 1y agoCompare

[ Source](https://github.com/alaa-hany-elsaid/ARB-Payment-Gateway)[ Packagist](https://packagist.org/packages/alaa-elsaid/arb)[ Docs](https://github.com/alaa-hany-elsaid/ARB-Payment-Gateway)[ GitHub Sponsors](https://github.com/egyjs)[ RSS](/packages/alaa-elsaid-arb/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (8)Versions (2)Used By (0)

Al Rajhi Bank payment gateway API wrapper (ARB)
===============================================

[](#al-rajhi-bank-payment-gateway-api-wrapper-arb)

[![GitHub Tests Action Status](https://camo.githubusercontent.com/f133caefe2c07fe3ae18793b188a6b5e6639743b8af6e96efd7a843cc2e98d2d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6567796a732f4152422d5061796d656e742d476174657761792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/egyjs/ARB-Payment-Gateway/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/10a63b9f76794229572df8b73624cdb8efe9011d518ceba56051b15d4e7ac5fa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6567796a732f4152422d5061796d656e742d476174657761792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/egyjs/ARB-Payment-Gateway/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/e5ddaf19f20f4c9210269e71fb5c65bd1a87f0e2fee395f544b67ada32f7c576/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6567796a732f6172622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/egyjs/arb)

This package is a wrapper around the Al Rajhi Bank payment gateway API, it allows you to initiate a payment request hosted on the Bank website or on the merchant website, and also allows you to refund a payment.

Support us
----------

[](#support-us)

[![](https://camo.githubusercontent.com/946e808d566704c088033cf0da5f653627099626b811fe08c657f5828fa7486f/68747470733a2f2f6769746875622d6164732e73332e65752d63656e7472616c2d312e616d617a6f6e6177732e636f6d2f4172622e6a70673f743d31)](https://spatie.be/github-ad-click/Arb)

We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us).

We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards).

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

[](#installation)

You can install the package via composer:

```
composer require alaa-elsaid/arb
```

You can publish the config file with:

```
php artisan vendor:publish --tag="arb-config"
```

This is the contents of the published config file:

```
return [
    'mode' => env('ARB_MODE', 'test'), // test or live
    'test_merchant_endpoint' => 'https://securepayments.alrajhibank.com.sa/pg/payment/tranportal.htm',
    'live_merchant_endpoint' => 'https://digitalpayments.alrajhibank.com.sa/pg/payment/tranportal.htm',
    'test_bank_hosted_endpoint' => 'https://securepayments.alrajhibank.com.sa/pg/payment/hosted.htm',
    'live_bank_hosted_endpoint' => 'https://digitalpayments.alrajhibank.com.sa/pg/payment/hosted.htm',
    'tranportal_id' => env('ARB_TRANPORTAL_ID'),
    'tranportal_password' => env('ARB_TRANPORTAL_PASSWORD'),
    "resource_key" => env('ARB_RESOURCE_KEY'), // your resource key
    "currency_code" => env('ARB_CURRENCY_CODE', '682'),
];
```

add the following to your `.env` file

```
ARB_MODE="test" # test or live
ARB_TRANPORTAL_ID="your_tranportal_id"
ARB_TRANPORTAL_PASSWORD="your_tranportal_password"
ARB_RESOURCE_KEY="your_resource_key"
ARB_CURRENCY_CODE="682" # "682" = SAR
```

Usage
-----

[](#usage)

### Bank hosted payment

[](#bank-hosted-payment)

to initiate a payment request hosted on the Bank website

```
use Alaa\Arb\Facades\Arb;

$responce = Arb::initiatePayment(100); // 100 to be paid

dd($responce);
/** @example
{#
  +"success": true
  +"url": "https://securepayments.alrajhibank.com.sa/pg/paymentpage.htm?PaymentID=?paymentId=000000000000000000"
}
*/
```

### merchant hosted payment

[](#merchant-hosted-payment)

to initiate a payment request hosted on the merchant website, you need to create a form for the card details, and pass the card details to the `Arb::card()` method, then call the `Arb::initiatePayment()` method as shown below

```
use Alaa\Arb\Facades\Arb;
use Alaa\Arb\Objects\Card;

Arb::card([
   'number' => '5105105105105100',
   'year' => '20'.'24',
   'month' => '12',
   'name' => 'AbdulRahman',
   'cvv' => '123',
   'type' => Card::CREDIT // or Card::DEBIT
]);
$responce = Arb::initiatePayment(100); // 100 to be paid

dd($responce);
/** @example
{#
  +"success": true
  +"url": "https://securepayments.alrajhibank.com.sa/pg/payment/hosted.htm?paymentId=000000000000000000&id=000x0bAdcEF0HfZ"
}
*/
```

### Refund a payment

[](#refund-a-payment)

to refund a payment you need to call the `Arb::refund()` method as shown below

```
use Alaa\Arb\Facades\Arb;

$responce = Arb::refund('000000000000000000', 100); // 100 to be refunded

dd($responce);
/** @example
{#
  +"success": true
  +"data": {}
}
*/
```

### manage data sent &amp; received from the bank

[](#manage-data-sent--received-from-the-bank)

to send custom data to the bank, you can use the `Arb::data()` method before any transaction as shown below

```
use Alaa\Arb\Facades\Arb;
Arb::data([
    'request_id' => 23,
    'user_id' => 43,
]);
// initiate a payment or make a refund
```

this data will be sent to the bank and will be returned in the response from the bank, `ArbPaymentSuccessEvent` will be fired with the received data from the bank as shown below

```
use Alaa\Arb\Events\ArbPaymentSuccessEvent;

Event::listen(ArbPaymentSuccessEvent::class, function (ArbPaymentSuccessEvent $event) {
    $response = $event->response;
    // to get the data sent to the bank
    $data = $response->getOriginalData();
});
```

> Note: you can listen to the `ArbPaymentSuccessEvent` in both ways: `EventServiceProvider::$listen` or `Event::listen()` method

### Handle the response

[](#handle-the-response)

egyjs/arb has a built-in [event driven architecture (EDA)](https://en.wikipedia.org/wiki/Event-driven_architecture) system to handle the response from the bank; you can listen to the `ArbPaymentSuccessEvent` event to handle the success response, and the `ArbPaymentFailedEvent` event to handle the fail response,

The use of events allows for decoupling between the processing logic and the actions taken upon success or failure. By emitting events, the processing logic doesn't need to know about or be tightly coupled to the actions taken upon success or failure. you can listen to the events in 2 ways:

1. using the `EventServiceProvider` class

```
use Alaa\Arb\Events\ArbPaymentFailedEvent;
use Alaa\Arb\Events\ArbPaymentSuccessEvent;

protected $listen = [
    // ...
    ArbPaymentSuccessEvent::class => [
        LogSuccessArbPaymentListener::class, // add any listener classes you want to handle the success payment
    ],
    ArbPaymentFailedEvent::class => [
        LogFailedArbPaymentListener::class, // add any listener classes you want to handle the failed payment
    ],
];
```

2. using the `Event::listen()` method

```
use Alaa\Arb\Events\ArbPaymentFailedEvent;
use Alaa\Arb\Events\ArbPaymentSuccessEvent;

Event::listen(ArbPaymentSuccessEvent::class, function (ArbPaymentSuccessEvent $event) {
    // handle the success payment
});

Event::listen(ArbPaymentFailedEvent::class, function (ArbPaymentFailedEvent $event) {
    // handle the failed payment
});
```

### handle the response in the controller

[](#handle-the-response-in-the-controller)

if you want to handle the using a custom route instead of the events, you can pass the success and fail urls to the `Arb::successUrl()` and `Arb::failUrl()` methods as shown below

```
use Alaa\Arb\Facades\Arb;

Arb::successUrl('http://localhost:8000/arb/response')
    ->failUrl('http://localhost:8000/arb/response');
$responce = Arb::initiatePayment(100); // 100 to be paid

dd($responce);
/** @example
{#
  +"success": true
  +"url": "http://localhost:8000/success/handle?paymentId=000000000000000000"
}
*/
```

your `/routes/web.php` file should look like this

```
use Illuminate\Http\Request;
Route::post('/arb/response', function (Request $request) {
    if ($request->status == 'success') {
        // handle the success payment
    } else {
        // handle the failed payment
    }
});
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [egyjs](https://github.com/egyjs)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance35

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.3% 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

Unknown

Total

1

Last Release

630d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2d553b830653f90ed7e6040c184d3ca29dc4a587c40f153a10dae608228f749e?d=identicon)[Alaa-Hany](/maintainers/Alaa-Hany)

---

Top Contributors

[![egyjs](https://avatars.githubusercontent.com/u/12745270?v=4)](https://github.com/egyjs "egyjs (26 commits)")[![alaa-hany-elsaid](https://avatars.githubusercontent.com/u/62419181?v=4)](https://github.com/alaa-hany-elsaid "alaa-hany-elsaid (1 commits)")

---

Tags

laravelegyjsarb

###  Code Quality

TestsPest

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/alaa-elsaid-arb/health.svg)

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

###  Alternatives

[vormkracht10/laravel-mails

Laravel Mails can collect everything you might want to track about the mails that has been sent by your Laravel app.

24149.7k](/packages/vormkracht10-laravel-mails)[danestves/laravel-polar

A package to easily integrate your Laravel application with Polar.sh

7812.3k](/packages/danestves-laravel-polar)[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)[creagia/laravel-redsys

Laravel Redsys Payments Gateway

2013.6k](/packages/creagia-laravel-redsys)

PHPackages © 2026

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