PHPackages                             tabbyai/laravel - 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. [API Development](/categories/api)
4. /
5. tabbyai/laravel

ActiveLibrary[API Development](/categories/api)

tabbyai/laravel
===============

Laravel package for integrating with Tabby.

2.1.1(1y ago)51.2k↓38.9%4MITPHP

Since Oct 24Pushed 1y ago1 watchersCompare

[ Source](https://github.com/sultan-algarbi/tabby-laravel-package)[ Packagist](https://packagist.org/packages/tabbyai/laravel)[ RSS](/packages/tabbyai-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (14)Used By (0)

Tabby Laravel Package
=====================

[](#tabby-laravel-package)

The **Tabby Laravel Package** (`tabbyai/laravel`) provides an easy-to-use integration with Tabby, a payment gateway service, allowing developers to create seamless checkout sessions within their Laravel applications.

Features
--------

[](#features)

1. **Easy Setup**: Install via Composer and configure with API keys.
2. **Checkout Management**: Create and retrieve checkout sessions, including payment URLs for easy redirection.
3. **Payment Management**: Retrieve, update, capture, refund, close payments, and list payments with filters.
4. **Webhook Management**: Register, retrieve, update, and delete webhooks to receive real-time event notifications.
5. **Error Handling**: Built-in exception management for smoother integration and user experience.

How to Use
----------

[](#how-to-use)

### Step 1: Installation

[](#step-1-installation)

To install the package via Composer, run:

```
composer require tabbyai/laravel
```

---

### Step 2: Configuration

[](#step-2-configuration)

Before you use the `TabbyService`, make sure you have the required API keys and configuration values. You need:

- `merchantCode` (your Tabby merchant code)
- `publicKey` (your Tabby public key)
- `secretKey` (your Tabby secret key)
- `currency` (default is `SAR` but can be changed)

---

### Step 3: Create an Instance of `TabbyService`

[](#step-3-create-an-instance-of-tabbyservice)

You need to initialize an instance of `TabbyService` by passing the necessary configuration values.

```
use Tabby\Services\TabbyService;

$tabbyService = new TabbyService(
    merchantCode: 'your_merchant_code',
    publicKey: 'your_public_key',
    secretKey: 'your_secret_key',
    currency: 'SAR' // Optional, default is SAR
);
```

---

### Step 4: Using Checkout Functions

[](#step-4-using-checkout-functions)

#### Creating a Checkout Session

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

To create a checkout session, you'll need the buyer's information, order details, and shipping address.

```
use Tabby\Models\Buyer;
use Tabby\Models\Order;
use Tabby\Models\ShippingAddress;
use Tabby\Models\OrderItem;

try {
    // Sample buyer data
    $buyer = new Buyer(
        phone: '500000001',
        email: 'card.success@tabby.ai',
        name: 'John Doe',
        dob: '1990-01-01',
    );

    // Sample order data
    $order = new Order(
        referenceId: 'order-001',
        items: [
            new OrderItem(
                title: 'Product Name',
                category: 'electronics',
                unitPrice: 100,
                quantity: 1,
                referenceId: 'prod-001',
                description: 'Product Description',
            ),
        ],
    );

    // Sample shipping address data
    $shippingAddress = new ShippingAddress(
        city: 'Al-Khobar',
        address: 'Street Address',
        zip: '12345',
    );

    // Create a checkout session
    $checkoutSession = $tabbyService->createSession(
        amount: 200,
        buyer: $buyer,
        order: $order,
        shippingAddress: $shippingAddress,
        description: 'order description',
        successCallback: 'https://example.com/success',
        cancelCallback: 'https://example.com/cancel',
        failureCallback: 'https://example.com/failure',
        // lang: 'ar',            // optional
        // buyerHistory: $buyerHistory,   // optional
        // orderHistory: $orderHistory,   // optional
    );

    // Fetch the payment url from the checkout session
    $paymentUrl = $checkoutSession->getPaymentUrl();

    // Redirect to the payment page
    return redirect($paymentUrl);
} catch (Exception $e) {
    // Handle exceptions
    return response()->json(['error' => $e->getMessage()], 500);
}
```

This will return a `CheckoutSession` object containing session details.

#### Retrieving a Checkout Session

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

To retrieve a previously created checkout session, use the session ID:

```
$checkoutSession = $tabbyService->retrieveCheckoutSession('session_id_here');
```

This will return a `CheckoutSession` object containing session details.

---

### Step 5: Using Payment Functions

[](#step-5-using-payment-functions)

#### Retrieve a Payment

[](#retrieve-a-payment)

To retrieve details of a specific payment by its ID:

```
$payment = $tabbyService->retrievePayment('payment_id_here');
```

#### Update a Payment

[](#update-a-payment)

```
$updatedPayment = $tabbyService->updatePayment(
    paymentId: 'payment_id_here',  // Payment ID
    referenceId: 'new_reference_id',  // Optional updated reference ID
    deliveryTracking: [
        ['tracking_number' => 'xxx', 'courier_code' => 'yyy']
    ],
);
```

#### Capture a Payment

[](#capture-a-payment)

Capture a payment after the transaction:

```
$capturedPayment = $tabbyService->capturePayment(
    paymentId: 'payment_id_here',  // Payment ID
    amount: 100.00, // Amount
    referenceId: 'reference_id_here' // Optional reference ID
);
```

#### Refund a Payment

[](#refund-a-payment)

```
$refundedPayment = $tabbyService->refundPayment(
    paymentId: 'payment_id_here',  // Payment ID
    amount: 50.00, // Amount to refund
    referenceId: 'reference_id_here', // Optional reference ID
    reason: 'refund reason' // Optional
);
```

#### Close a Payment

[](#close-a-payment)

```
$closedPayment = $tabbyService->closePayment('payment_id_here');
```

#### List of Payments

[](#list-of-payments)

```
list($payments, $pagination) = $tabbyService->listPayments(
    createdAtGte: '', // Optional
    createdAtLte: '', // Optional
    status: null, // Optional
    limit: 10, // Optional
    offset: 0, // Optional
);
```

---

### Step 6: Using Webhook Functions

[](#step-6-using-webhook-functions)

#### Register a Webhook

[](#register-a-webhook)

To register a new webhook for receiving events from Tabby:

```
$webhook = $tabbyService->registerWebhook(
    url: 'https://your-domain.com/webhook-url',  // URL to receive webhook notifications
    isTest: true,  // Test mode (optional)
    headerTitle: 'Custom-Header-Title',  // Optional
    headerValue: 'Custom-Header-Value'  // Optional
);
```

#### Retrieve All Webhooks

[](#retrieve-all-webhooks)

To retrieve all registered webhooks:

```
$webhooks = $tabbyService->retrieveAllWebhooks();
```

#### Retrieve a Specific Webhook

[](#retrieve-a-specific-webhook)

```
$webhook = $tabbyService->retrieveWebhook('webhook_id_here');
```

#### Update a Webhook

[](#update-a-webhook)

```
$webhook = $tabbyService->updateWebhook(
    webhookId: 'webhook_id_here',
    url: 'https://your-domain.com/webhook-url',  // URL to receive webhook notifications
    isTest: true,  // Test mode
);
```

#### Delete a Specific Webhook

[](#delete-a-specific-webhook)

```
$webhook = $tabbyService->deleteWebhook('webhook_id_here');
```

---

Exception Handling
------------------

[](#exception-handling)

The package throws exceptions for any failed API requests or missing configuration. Ensure to handle them properly in your code to provide a smooth user experience.

```
try {
    // your code
} catch (Exception $e) {
    // handle the error
}
```

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity46

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

Total

13

Last Release

550d ago

Major Versions

1.0.5 → 2.0.02024-11-12

### Community

Maintainers

![](https://www.gravatar.com/avatar/6f12e0fabd4b4de02155b5792a38488336f6bde34d8aef4c01978f8804889840?d=identicon)[SultanAlgarbi](/maintainers/SultanAlgarbi)

---

Tags

apisdkpackagepaymentintegrationpayment gatewaytabby

### Embed Badge

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

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

PHPackages © 2026

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