PHPackages                             ialtoobi/thawani - 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. ialtoobi/thawani

ActiveLibrary[Payment Processing](/categories/payments)

ialtoobi/thawani
================

A Laravel package for integrating Thawani payment gateway.

1.3(1y ago)328↓100%MITPHPPHP ^7.3|^8.0

Since Feb 26Pushed 1y ago1 watchersCompare

[ Source](https://github.com/ialtoobi/Thawani-Manager)[ Packagist](https://packagist.org/packages/ialtoobi/thawani)[ RSS](/packages/ialtoobi-thawani/feed)WikiDiscussions main Synced 1mo ago

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

Thawani Manager
---------------

[](#thawani-manager)

Thawani Manager is a Laravel package designed to simplify interactions with the Thawani payment gateway API, enabling easy integration of Thawani payment solutions into your Laravel application.

Features
--------

[](#features)

- Create and manage checkout sessions
- Handle customer information and payment methods
- Generate payment URLs for redirecting users to the Thawani payment page
- Process payments through Thawani's API

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

[](#installation)

### 1. Require the Package

[](#1-require-the-package)

Use Composer to add the package to your Laravel project:

```
composer require ialtoobi/thawani
```

or clone the package using GIT:

git clone or Download the archive by [clicking here](https://github.com/ialtoobi/Thawani-Manager/archive/master.zip).

### 2. Publish Configuration

[](#2-publish-configuration)

Publish the package configuration to customize settings like (Mode, Secret Key, Publishable Key):

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

### 3. Configure Environment Variables

[](#3-configure-environment-variables)

To configure your application to work with Thawani Pay, you need to set the following variables in your **.env file**. These settings will specify whether your application is in testing or production mode, provide the necessary API keys for production environment.

- THAWANI\_MODE: Set this to either 'test' or 'live' based on your environment. This determines which set of API keys and endpoints the ThawaniManager will use.
- THAWANI\_LIVE\_SECRET\_KEY: This is your live secret key provided by Thawani Pay. It is used to authenticate server-side API requests to Thawani.
- THAWANI\_LIVE\_PUBLISHABLE\_KEY=: This is your live publishable key provided by Thawani Pay. It is used to authenticate client-side requests.

```
THAWANI_MODE=test
THAWANI_LIVE_SECRET_KEY=your_live_secret_key
THAWANI_LIVE_PUBLISHABLE_KEY=your_live_publishable_key
```

Usage
-----

[](#usage)

### Creating a Checkout Session To Generate Payment URL

[](#creating-a-checkout-session-to-generate-payment-url)

To create a new checkout session and redirect the user to the Thawani payment page:

```
use Ialtoobi\Thawani\ThawaniManager;
use Illuminate\Support\Facades\Session;

$thawani = new ThawaniManager();

$data = [
    "client_reference_id" => "123412",
    "mode" => "payment",
    "products" => [
        [
            "name" => "product 1",
            "quantity" => 1,
            "unit_amount" => 100,
        ],
    ],
    "success_url" => "https://company.com/success",
    "cancel_url" => "https://company.com/cancel",
    "metadata" => [
        "Customer name" => "ialtoobi",
        "order id" => 0,
    ],
];

$create_checkout_session_result = $thawani->createCheckoutSession($data);

if ($create_checkout_session_result) {

    $session_id = $create_checkout_session_result['session_id'];
    $redirect_url = $create_checkout_session_result['redirect_url'];

    // Save session_id for later use, such as confirming payment status
    Session::put('session_id', $session_id);

    return redirect($redirect_url);
}else {
    // Handle errors or unsuccessful attempts here, such as logging the error or notifying the user
}
```

### Retrieving a Checkout Session

[](#retrieving-a-checkout-session)

To retrieve details of an existing checkout session use `session_id`:

```
// Assume $session_id is retrieved from a previous step or stored session
$session_id = 'your_session_id_here';

$retrieve_checkout_session_result  = $thawani->retrieveCheckoutSession($session_id);

$payment_status = $retrieve_checkout_session_result['data']['status'];

//Check payment status
if ($payment_status === 'paid') {
    // Handle successful payment
    // This could include updating order status in your database
}
```

### Managing Customers:

[](#managing-customers)

Create a customer to save card for later payment:

Make sure you provide created `customer_id` in create checkout session.

```
// Use a unique string to reference your customer
$customer_data = [
    "client_customer_id": "customer_email@mail.com"
];

$create_customer_result = $thawani->createCustomer($customer_data);

//Save `customer_id` in the database to use for payment intent later
$customer_id = $create_customer_result['data']['id'];
```

To retrieve a customer use `customer_id`:

```
$customer_id = 'your_customer_id_here';

$retrieve_customer_result = $thawani->retrieveCustomer($customer_id);

$data = $retrieve_customer_result['data'];
```

To delete a customer use `customer_id`:

```
$customer_id = 'your_customer_id_here';

$delete_customer_result = $thawani->deleteCustomer($customer_id);

$description = $delete_customer_result['description'];
```

### Handling Payments:

[](#handling-payments)

To get list of saved payment methods related to customer use `customer_id`:

```
$customer_id = 'your_customer_id_here';

$customer_payment_method_result = $thawani->customerPaymentMethod($customer_id);

//Example: select first `payment_method_id` to create payment intent later
$payment_method_id = $customer_payment_method_result['data'][0]['id'];
```

To delete a payment method use `card_id`:

```
$card_id = 'card_id';

$payment_method_result = $thawani->deletePaymentMethod($card_id);

$description = $payment_method_result['description'];
```

### Payment Intent

[](#payment-intent)

To create a payment intent:

```
$paymentData = [
    "payment_method_id" => $payment_method_id,
    "amount" => 100,
    "client_reference_id" => 1234,
    "return_url" => "https://company.com/success",
    "metadata" => [
        "customer_name" => 'Mohammed Al-Toubi',
        "order_id" => 1
    ]
];

$payment_intent_id = $thawani->createPaymentIntent($paymentData);
```

To confirm a payment intent:

```
$payment_intent_id = 'your_payment_intent_id_here';

$confirm_payment_intent_result = $thawani->confirmPaymentIntent($payment_intent_id);

if ($confirm_payment_intent_result) {

    $payment_id = $confirm_payment_intent_result['payment_id'];
    $redirect_url = $confirm_payment_intent_result['redirect_url'];

    // Save payment_id for later use, such as confirming payment status
    Session::put('payment_id', $payment_id);

    return redirect($redirect_url);
}else {
    // Handle errors or unsuccessful attempts here, such as logging the error or notifying the user
}
```

To retrieve details of payment intent use `payment_intent_id`:

```
// Assume $payment_id is retrieved from a previous step or stored session
$payment_id = 'your_payment_id_here';

$retrieve_payment_intent_result  = $thawani->retrievePaymentIntent($payment_id);

$payment_status = $retrieve_payment_intent_result['data']['status'];

//Check payment status
if ($payment_status === 'succeeded') {
    // Handle successful payment
    // This could include updating order status in your database
}
```

To cancel paymant intent use `payment_intent_id`:

```
$payment_intent_id = 'your_payment_intent_id_here';

$cancel_payment_intent_result = $thawani->cancelPaymentIntent($payment_intent_id);

$description = $cancel_payment_intent_result['description'];
```

Support
-------

[](#support)

For issues, questions, or contributions, please open an issue on the GitHub repository: [clicking here](https://github.com/ialtoobi/Thawani-Manager)

#### Follow me on X [@ialtoobi](https://x.com/ialtoobi/)

[](#follow-me-on-x-ialtoobi)

License
-------

[](#license)

Thawani Manager is open-sourced package licensed under the MIT license.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance32

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

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 ~33 days

Total

4

Last Release

704d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/2cad1f570e08d8bdd12ebc81e4229df87aadd898121dbe5eeaeb73914994dc8f?d=identicon)[ialtoobi](/maintainers/ialtoobi)

---

Tags

laravelpayment gatewaythawani

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[luigel/laravel-paymongo

A laravel wrapper for Paymongo API

7956.2k1](/packages/luigel-laravel-paymongo)[hexters/coinpayment

CoinPayment is a Laravel module for handling transactions from CoinPayment like a create transaction, history transaction, etc.

7058.0k](/packages/hexters-coinpayment)[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)[victorybiz/laravel-crypto-payment-gateway

GoUrl.io Crypto Payment Gateway for Laravel

642.5k](/packages/victorybiz-laravel-crypto-payment-gateway)

PHPackages © 2026

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