PHPackages                             aghfatehi/laravel-tamara - 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. aghfatehi/laravel-tamara

ActiveLibrary[Payment Processing](/categories/payments)

aghfatehi/laravel-tamara
========================

Tamara Payment Gateway Integration for Laravel - Buy Now Pay Later (BNPL) solution supporting Saudi Arabia, UAE, Kuwait, Bahrain, Qatar, and Oman.

v1.0.1(1mo ago)09MITPHPPHP ^8.1

Since May 30Pushed 1mo agoCompare

[ Source](https://github.com/aghfatehi/laravel-tamara)[ Packagist](https://packagist.org/packages/aghfatehi/laravel-tamara)[ RSS](/packages/aghfatehi-laravel-tamara/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (1)Dependencies (7)Versions (3)Used By (0)

Laravel Tamara Payment Gateway
==============================

[](#laravel-tamara-payment-gateway)

[![Latest Version](https://camo.githubusercontent.com/88c5e76d28e08f8dfd5ba0f54699df50b816f643f658b55970b15735ba2e6d63/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6167686661746568692f6c61726176656c2d74616d6172612e737667)](https://packagist.org/packages/aghfatehi/laravel-tamara)[![Laravel](https://camo.githubusercontent.com/1d4df8c9d8bf1a1465f577903a42fcb626084557c088724af28821792b65b734/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31307e31332d7265642e737667)](https://laravel.com)[![PHP](https://camo.githubusercontent.com/45d36955804bf3f4f17097b05a7f41a28e578dc24e0d3ad0d21ae9d9762f44c6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312b2d626c75652e737667)](https://php.net)[![License](https://camo.githubusercontent.com/481905670a82a07b8628fc712a8f88e74f4cbc377f9ebbefcad9abfc4427b952/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6167686661746568692f6c61726176656c2d74616d617261)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/b951a35ccb9954f946ab58e5ba4e861304cf532cbc40fcccb4c2d464c9b564fc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6167686661746568692f6c61726176656c2d74616d6172612e737667)](https://packagist.org/packages/aghfatehi/laravel-tamara)

A professional Laravel package for integrating [Tamara](https://tamara.co) - the leading Buy Now Pay Later (BNPL) payment solution in the Middle East. Supports Saudi Arabia, UAE, Kuwait, Bahrain, Qatar, and Oman.

Features
--------

[](#features)

- ✅ Full Tamara Online Checkout flow
- ✅ Payment Types lookup
- ✅ Create Checkout Sessions
- ✅ Authorise / Capture / Cancel / Refund orders
- ✅ Webhook management (register, list, update, delete)
- ✅ Sandbox &amp; Production environments
- ✅ Multi-currency support (SAR, AED, KWD, BHD, QAR, OMR)
- ✅ Multi-country support (SA, AE, KW, BH, QA, OM)
- ✅ In-store checkout support
- ✅ cURL HTTP client (no Guzzle)
- ✅ Configurable routes prefix &amp; middleware
- ✅ Transaction logging migration
- ✅ Laravel 10, 11, 12 &amp; 13 compatible
- ✅ PHP 8.1+

Requirements
------------

[](#requirements)

LaravelPHPPackage Version10.x^8.1^1.011.x^8.2^1.012.x^8.2^1.013.x^8.2^1.0Installation
------------

[](#installation)

```
composer require aghfatehi/laravel-tamara
```

Configuration
-------------

[](#configuration)

### 1. Publish Configuration

[](#1-publish-configuration)

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

### 2. Publish Migration (Optional)

[](#2-publish-migration-optional)

```
php artisan vendor:publish --tag=tamara-migrations
php artisan migrate
```

### 3. Environment Variables

[](#3-environment-variables)

Add these to your `.env` file:

```
TAMARA_SANDBOX_MODE=true              # true = sandbox, false = production
TAMARA_API_TOKEN=your-api-token-here  # API token from Tamara Merchant Dashboard
TAMARA_COUNTRY_CODE=SA                # SA, AE, KW, BH, QA, OM
TAMARA_CURRENCY=SAR                   # SAR, AED, KWD, BHD, QAR, OMR
TAMARA_INSTALMENTS=3                  # Number of instalments (3, 6, 12)
TAMARA_PAYMENT_TYPE=PAY_BY_INSTALMENTS # PAY_BY_INSTALMENTS or PAY_NEXT_MONTH
TAMARA_LOCALE=en_US                   # en_US or ar_SA
TAMARA_LOGGING=true                   # Enable API request/response logging
# true = enabled | false = disabled
TAMARA_ROUTE_PREFIX=tamara            # URL prefix for package routes
```

### 4. Service Provider

[](#4-service-provider)

The package auto-discovers via Laravel's package discovery. If you disable discovery, register manually in `config/app.php`:

```
'providers' => [
    Aghfatehi\Tamara\TamaraServiceProvider::class,
],
```

### 5. Facade (Optional)

[](#5-facade-optional)

```
'aliases' => [
    'Tamara' => Aghfatehi\Tamara\Facades\Tamara::class,
],
```

Usage
-----

[](#usage)

### Quick Start - Frontend Checkout

[](#quick-start---frontend-checkout)

```
use Aghfatehi\Tamara\Facades\Tamara;

// Get available payment types
$types = Tamara::getPaymentTypes('SA', 'SAR', 500);

// Build checkout request body with example values
$requestbody = [
    'total_amount' => [                          // Order total amount
        'amount' => 500,
        'currency' => 'SAR',
    ],
    'shipping_amount' => [                       // Shipping cost
        'amount' => 0,
        'currency' => 'SAR',
    ],
    'tax_amount' => [                            // Tax amount
        'amount' => 0,
        'currency' => 'SAR',
    ],
    'order_reference_id' => uniqid('tamara_'),   // Unique order reference
    'order_number' => 'ORD-' . time(),            // Merchant order number
    'items' => [                                  // Order items (max 50)
        [
            'name' => 'Order Payment',
            'type' => 'Digital',                  // Digital or Physical
            'reference_id' => '1',                // Item ID in your system
            'sku' => 'PAYMENT-001',
            'quantity' => 1,
            'unit_price' => [                     // Price per unit
                'amount' => 500,
                'currency' => 'SAR',
            ],
            'total_amount' => [                   // quantity * unit_price
                'amount' => 500,
                'currency' => 'SAR',
            ],
        ],
    ],
    'consumer' => [                               // Customer details
        'email' => 'customer@example.com',
        'first_name' => 'Ahmed',
        'last_name' => 'Ali',
        'phone_number' => '500000000',            // Without country code prefix
    ],
    'country_code' => 'SA',                       // SA, AE, KW, BH, QA, OM
    'description' => 'Payment for order',
    'merchant_url' => [                           // Callback URLs (with optional reference_id)
        'success' => route('tamara.callback', ['reference_id' => 'ORD-12345']),
        'failure' => route('tamara.failure', ['reference_id' => 'ORD-12345']),
        'cancel' => route('tamara.cancel', ['reference_id' => 'ORD-12345']),
        'notification' => route('tamara.webhook'),
    ],
    'payment_type' => 'PAY_BY_INSTALMENTS',       // PAY_BY_INSTALMENTS or PAY_NEXT_MONTH
    'instalments' => 3,                           // 3,4 or 6
    'billing_address' => [                        // Billing address
        'city' => 'Riyadh',
        'country_code' => 'SA',
        'first_name' => 'Ahmed',
        'last_name' => 'Ali',
        'line1' => 'Default Address',
        'phone_number' => '500000000',
    ],
    'shipping_address' => [                       // Shipping address
        'city' => 'Riyadh',
        'country_code' => 'SA',
        'first_name' => 'Ahmed',
        'last_name' => 'Ali',
        'line1' => 'Default Address',
        'phone_number' => '500000000',
    ],
    'platform' => 'Laravel',                      // Platform name
    'is_mobile' => false,                         // true if mobile app
    'locale' => 'en_US',                          // en_US or ar_SA
];

// Create checkout session
$response = Tamara::createCheckout($requestbody);

// Redirect customer to Tamara checkout
if (isset($response['checkout_url'])) {
    return redirect()->away($response['checkout_url']);
}

// Handle errors
if (isset($response['errors'])) {
    $errorMessage = $response['errors'][0]['message'] ?? 'Payment failed';
    return back()->with('error', $errorMessage);
}
```

### Using Routes

[](#using-routes)

The package registers these routes under the configured prefix (`/tamara` by default):

MethodURINameDescriptionGET`/tamara/payment/types``tamara.payment.types`Get eligible payment typesPOST`/tamara/pay``tamara.pay`Initiate checkoutANY`/tamara/callback``tamara.callback`Payment callbackGET`/tamara/cancel``tamara.cancel`Cancel handlerGET`/tamara/failure``tamara.failure`Failure handlerPOST`/tamara/webhook``tamara.webhook`Webhook receiverPOST`/tamara/authorise``tamara.authorise`Authorise order### API Methods

[](#api-methods)

```
// Payment Types
$types = Tamara::getPaymentTypes('SA', 'SAR', 500, '500000000');

// Checkout
$checkout = Tamara::createCheckout($data);

// Order Management
$order = Tamara::getOrder('order-id-here');
$order = Tamara::getOrderByReferenceId('ref-id-here');

// Authorise / Capture / Cancel / Refund
$authorised = Tamara::authoriseOrder('order-id');
$captured = Tamara::captureOrder('order-id', $data);
$cancelled = Tamara::cancelOrder('order-id', $data);
$refunded = Tamara::refundOrder('order-id', 500, 'SAR', 'Refund comment');

// Webhook Management
$webhook = Tamara::webhookRegister('https://example.com/webhook', [
    'order_approved',
    'order_declined',
    'order_authorised',
    'order_captured',
    'order_refunded',
]);
$list = Tamara::webhookList();
$detail = Tamara::webhookGet('webhook-id');
Tamara::webhookDelete('webhook-id');
Tamara::webhookUpdate('webhook-id', 'https://example.com/webhook', [...]);
```

### Route Parameters

[](#route-parameters)

Pass `reference_id` when calling `POST /tamara/pay`. It will be forwarded as a query parameter to the callback, cancel, and failure URLs so your app can identify the order when Tamara redirects back.

```
// Example: POST /tamara/pay with reference_id
$response = Http::post(url('/tamara/pay'), [
    'amount' => 500,
    'order_reference_id' => 'ORD-12345',
    'reference_id' => 'combined_order_42',
    'order_number' => 'INV-2025-001',
    'item_reference_id' => 'product_1',
]);
```

ParameterTypeDescription`reference_id`stringPassed as `?reference_id=` in callback URLs for order identification`order_reference_id`stringYour internal order reference (sent to Tamara API)`order_number`stringYour order number (sent to Tamara API)`item_reference_id`stringItem reference ID within the orderCustomising Routes
------------------

[](#customising-routes)

Publish the config and modify the `routes` section:

```
// config/tamara.php
'routes' => [
    'prefix' => 'payment/tamara',     // Custom prefix
    'middleware' => ['web', 'auth'],   // Custom middleware
],
```

Handling Webhooks
-----------------

[](#handling-webhooks)

The webhook endpoint logs all incoming events. Extend the controller or listen to the log to implement your business logic:

```
// Example webhook payload handling
public function webhook(Request $request)
{
    $event = $request->input('event_type');
    $orderId = $request->input('order_id');
    $status = $request->input('status');

    switch ($event) {
        case 'order_approved':
            // Mark order as approved
            break;
        case 'order_captured':
            // Fulfill the order
            break;
        case 'order_refunded':
            // Process refund
            break;
    }
}
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

See [CHANGELOG](CHANGELOG.md) for recent changes.

Security
--------

[](#security)

If you discover security issues, please email  instead of using the issue tracker.

License
-------

[](#license)

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

Support
-------

[](#support)

- **Issues**: [GitHub Issues](https://github.com/aghfatehi/laravel-tamara/issues)
- **Tamara Docs**:
- **Author**: AL-AGHBARI Fatehi ()

Countries &amp; Currencies
--------------------------

[](#countries--currencies)

CountryCodeCurrencyCodeSaudi ArabiaSARiyalSARUAEAEDirhamAEDKuwaitKWDinarKWDBahrainBHDinarBHDQatarQARiyalQAROmanOMRiyalOMR

###  Health Score

37

—

LowBetter than 81% of packages

Maintenance92

Actively maintained with recent releases

Popularity4

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity43

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

Total

2

Last Release

54d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c0d20683d29aa61fca6b1f9a47a754b2d3e177750f1e8d66975979f2ae8813f?d=identicon)[aghfatehi](/maintainers/aghfatehi)

---

Tags

api-integrationbnplbuy-now-pay-latercheckoutecommercefintechfintech-apigcc-paymentskuwaitlaravellaravel-packagepayment-gatewaypayment-processingphpsaudi-arabiatamaratamara-payuaewebhookslaravelpaymentgatewaytamarasaudi-arabiainstallmentsbnpluae

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

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

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

###  Alternatives

[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

77922.3M186](/packages/laravel-mcp)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.3M347](/packages/psalm-plugin-laravel)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9762.4M133](/packages/roots-acorn)[api-platform/laravel

API Platform support for Laravel

58174.6k17](/packages/api-platform-laravel)[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4851.0k](/packages/sebdesign-laravel-viva-payments)

PHPackages © 2026

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