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

ActiveLibrary

tahdir/arb
==========

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

00PHP

Since Dec 26Pushed 1y agoCompare

[ Source](https://github.com/maldoukhi/ARB-Payment-Gateway)[ Packagist](https://packagist.org/packages/tahdir/arb)[ RSS](/packages/tahdir-arb/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (1)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/22c76142c2cf065c7f78723c1bd1fff27c55b9813e2251f063411ec82219e7a3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7461686469722f6172622d5061796d656e742d476174657761792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/tahdir/arb-Payment-Gateway/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/52d841173d925d06ce1d79f6a15eb6eca4981c71c8bc7e2c8586f96576911091/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7461686469722f6172622d5061796d656e742d476174657761792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/tahdir/arb-Payment-Gateway/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/6752177080d914985e1c06fb88912f2e4a09a1658e773bb79ba987bc7d7e7735/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7461686469722f6172622e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tahdir/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 tahdir/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 Tahdir\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 Tahdir\Arb\Facades\Arb;
use Tahdir\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 Tahdir\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 Tahdir\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 Tahdir\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)

tahdir/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 Tahdir\Arb\Events\ArbPaymentFailedEvent;
use Tahdir\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 Tahdir\Arb\Events\ArbPaymentFailedEvent;
use Tahdir\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 Tahdir\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

14

—

LowBetter than 2% of packages

Maintenance31

Infrequent updates — may be unmaintained

Popularity0

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity16

Early-stage or recently created project

 Bus Factor1

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

### Community

Maintainers

![](https://www.gravatar.com/avatar/cedfd1930b08be1e1571d3775eecb5bc3fdf518e76dfae8aa7fd781bb924b70f?d=identicon)[maldoukhi](/maintainers/maldoukhi)

---

Top Contributors

[![egyjs](https://avatars.githubusercontent.com/u/12745270?v=4)](https://github.com/egyjs "egyjs (26 commits)")[![maldoukhi](https://avatars.githubusercontent.com/u/155090830?v=4)](https://github.com/maldoukhi "maldoukhi (7 commits)")

### Embed Badge

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

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

PHPackages © 2026

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