PHPackages                             fateel-tech/moyasar-php - 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. fateel-tech/moyasar-php

ActiveLibrary[Payment Processing](/categories/payments)

fateel-tech/moyasar-php
=======================

Modern PHP SDK for Moyasar Payment Gateway

v1.1.0(7mo ago)3169MITPHPPHP &gt;=8.1

Since Sep 22Pushed 7mo agoCompare

[ Source](https://github.com/Fateel-Tech/moyasar-php)[ Packagist](https://packagist.org/packages/fateel-tech/moyasar-php)[ RSS](/packages/fateel-tech-moyasar-php/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (9)Versions (3)Used By (0)

🚀 Moyasar PHP SDK
=================

[](#-moyasar-php-sdk)

A modern, easy-to-use PHP SDK for Moyasar Payment Gateway with built-in Laravel integration.

[![PHP Version](https://camo.githubusercontent.com/854124dd57cfd3aad3184fca9760bf1f33a5ec1e5d080cfbe8aa4e3337ba46e6/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e302d3838393242462e737667)](https://www.php.net/)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)

⚠️ Important Notice
-------------------

[](#️-important-notice)

**We are NOT Moyasar.** We are **Fateel Tech**, an independent IT company that builds solutions for our clients. Since the official Moyasar PHP package was abandoned and no longer maintained, we decided to create and maintain this modern SDK to make integration easier for the community.

**Fateel Tech** is an official partner with Moyasar, ensuring this package stays up-to-date with their latest API changes and best practices.

🚨 Migration from moyasar/moyasar-php
------------------------------------

[](#-migration-from-moyasarmoyasar-php)

**This SDK is not a drop-in replacement for the abandoned moyasar/moyasar package.** While it covers the same core functionality (Payments, Invoices), the API design and usage patterns have been modernized and we have included support for tokenization and webhooks. As a result, existing code using the old SDK will need to be updated.

### 🔄 Quick Migration Guide

[](#-quick-migration-guide)

**Old Way (moyasar/moyasar-php):**

```
use Moyasar\Providers\PaymentService;
use Moyasar\Providers\InvoiceService;
use Moyasar\Facades\Moyasar;

// Fetch payment
$paymentService = new PaymentService();
$payment = $paymentService->fetch('payment_id');

// Create invoice
$invoiceService = new InvoiceService();
$invoice = $invoiceService->create(['amount' => 1000, 'currency' => 'SAR']);

// Basic Laravel facade
$payment = \Moyasar\Facades\Payment::fetch('id');

// Limited search capabilities
$search = \Moyasar\Search::query()->status('paid')->page(2);
$paginationResult = $paymentService->all($search);

// No tokenization support
// No webhook management
// No metadata search
```

**New Way (fateel-tech/moyasar-php):**

```
use FateelTech\Moyasar\Laravel\Facades\Moyasar;
use FateelTech\Moyasar\Enums\Currency;
use FateelTech\Moyasar\Enums\WebhookEvent;

// Fetch payment
$payment = Moyasar::payments()->find('payment_id');

// Create invoice with enums
$invoice = Moyasar::invoices()->create(
    amount: 1000,
    currency: Currency::SAR
);

// NEW: Tokenization support
$payment = Moyasar::payments()->createWithToken(
    token: 'token_abc123',
    amount: 5000,
    description: 'Payment with saved card'
);

// NEW: Webhook management
$webhook = Moyasar::webhooks()->create(
    url: 'https://yourapp.com/webhooks',
    events: [WebhookEvent::PAYMENT_PAID]
);

// NEW: Enhanced search with metadata filtering
$payments = Moyasar::payments()->list(
    page: 1,
    status: PaymentStatus::PAID,
    metadata: ['order_id' => '12345'],
    cardLastDigits: '1234',
    createdGt: '2024-01-01'
);

// NEW: Artisan commands
php artisan moyasar:make-webhook
php artisan moyasar:webhook list
```

**Key improvements:** Modern PHP 8.0+, tokenized card payments, webhook management, **metadata search**, strongly typed responses, comprehensive Laravel integration.

🛣️ Roadmap
----------

[](#️-roadmap)

We're actively working to provide complete Moyasar API coverage. The following features are on our roadmap:

- ✅ **Settlement API** - *Completed*
- **Sources API**
- **Payouts API**
- **Transfers API**

**🤝 Contributions Welcome!** If you'd like to help implement any of these features, please feel free to submit a pull request or open an issue to discuss implementation details.

### 🤝 Need Custom Development?

[](#-need-custom-development)

If you need custom payment integrations, Laravel applications, or any other development services, feel free to reach out to us:

**Contact Fateel Tech:**

We specialize in:

- 💳 Payment gateway integrations
- 🛠️ Custom Laravel applications
- 🔧 API development and integrations
- 📱 Mobile and web applications

---

✨ Features
----------

[](#-features)

- 💳 **Full API Coverage**: Payments, Invoices, Tokens, Webhooks, Settlements.
- 🔒 **Strongly Typed**: Robust DTOs and enums ensure type safety.
- 🚀 **Laravel Integration**: Seamless Laravel integration with DI, Facades, and Artisan commands.
- 🔔 **Webhook Management**: Easily generate and manage webhooks with Artisan commands.
- 🎯 **Framework Agnostic**: Use with any PHP framework or vanilla PHP.

---

📦 Installation
--------------

[](#-installation)

```
composer require fateel-tech/moyasar-php
```

---

⚡ Quick Start
-------------

[](#-quick-start)

### Pure PHP

[](#pure-php)

```
use FateelTech\Moyasar\MoyasarClient;

$moyasar = new MoyasarClient('sk_test_your_key');

// Create payment
$payment = $moyasar->payments()->createWithToken(
    token: 'token_abc123',
    amount: 5000,
    description: 'Test payment'
);

// Find payment
$payment = $moyasar->payments()->find('pay_abc123');

// List payments
$payments = $moyasar->payments()->list();
```

### Laravel

[](#laravel)

Publish configuration and set keys:

```
# Publish configuration only
php artisan vendor:publish --tag=moyasar-config

# Or publish everything from the provider
php artisan vendor:publish --provider="FateelTech\Moyasar\Laravel\MoyasarServiceProvider"
```

**.env**

```
MOYASAR_API_KEY=sk_test_your_secret_key
MOYASAR_PUBLISHABLE_API_KEY=pk_test_your_publishable_key
MOYASAR_WEBHOOK_SECRET=your_webhook_secret
```

---

🎯 Usage
-------

[](#-usage)

### Dependency Injection

[](#dependency-injection)

```
use FateelTech\Moyasar\MoyasarClient;

class PaymentController
{
    public function __construct(private MoyasarClient $moyasar) {}

    public function showPayment(Request $request)
    {
        $payment = $this->moyasar->payments()->find($request->payment_id);

        if ($payment->isCompleted()) {
            // Process successful payment
        }
    }
}
```

### Facade

[](#facade)

```
use FateelTech\Moyasar\Laravel\Facades\Moyasar;

$payment = Moyasar::payments()->createWithToken(
    token: 'token_abc123',
    amount: 5000,
    description: 'Order #1234'
);
```

### Blade Helpers

[](#blade-helpers)

```
>

    @moyasarStyles

    @moyasarScripts

        Moyasar.init({
            element: '.mysr-form',
            amount: {{ $order->total_in_halalas }},
            currency: 'SAR',
            description: 'Order #{{ $order->id }}',
            publishable_api_key: '@moyasarPublishableKey',
            callback_url: '{{ route("payment.callback") }}',
            methods: ['creditcard', 'stcpay'],
            metadata: { order_id: '{{ $order->id }}' }
        });

```

---

🔔 Webhooks - Complete Guide
---------------------------

[](#-webhooks---complete-guide)

### 🚀 Quick Setup with make-webhook Command

[](#-quick-setup-with-make-webhook-command)

**The `moyasar:make-webhook` command does everything for you:**

1. **Creates the webhook in Moyasar** - Registers with the payment gateway
2. **Generates scaffold controller** - Basic event handling structure
3. **Adds route automatically** - Ready-to-use webhook endpoint

```
# Complete webhook setup in one command
php artisan moyasar:make-webhook payment https://yourapp.com/api/webhooks/payment your_webhook_secret --events=payment_paid,payment_failed --controller --route

# This creates:
# - Webhook registered with Moyasar
# - PaymentWebhookController with event handling
# - Route added to routes/web.php
# - Ready for immediate use and customization
```

### 📦 Optional: Publish Request Classes

[](#-optional-publish-request-classes)

```
# Publish webhook request classes for custom validation
php artisan vendor:publish --tag=moyasar-requests
```

### 🛠️ Manual Webhook Creation

[](#️-manual-webhook-creation)

For pure PHP or custom Laravel setups:

```
use FateelTech\Moyasar\Enums\WebhookEvent;

$webhook = $moyasar->webhooks()->create(
    httpMethod: 'post',
    url: 'https://yourapp.com/api/webhooks/payment',
    sharedSecret: 'your_webhook_secret',
    events: [WebhookEvent::PAYMENT_PAID, WebhookEvent::PAYMENT_FAILED]
);
```

### 📊 Available Events

[](#-available-events)

> 💡 **View Complete List:** [WebhookEvent.php](src/Enums/WebhookEvent.php) with descriptions and helper methods.

**Most Used Payment Events:**

```
WebhookEvent::PAYMENT_PAID        // ✅ Payment completed successfully
WebhookEvent::PAYMENT_FAILED      // ❌ Payment failed
WebhookEvent::PAYMENT_AUTHORIZED  // 🔒 Payment authorized (not captured)
WebhookEvent::PAYMENT_CAPTURED    // 💰 Payment captured
```

**Post-Payment Events:**

```
WebhookEvent::PAYMENT_REFUNDED    // 💸 Payment refunded
WebhookEvent::PAYMENT_VOIDED      // ⚫ Payment voided
WebhookEvent::PAYMENT_ABANDONED   // 🚪 Payment abandoned by customer
WebhookEvent::PAYMENT_CANCELED    // ❌ Payment canceled
WebhookEvent::PAYMENT_EXPIRED     // ⏰ Payment expired
WebhookEvent::PAYMENT_VERIFIED    // ✔️ Payment verified
```

**Payout &amp; Balance Events:**

```
WebhookEvent::PAYOUT_PAID         // 💳 Payout completed
WebhookEvent::PAYOUT_FAILED       // ❌ Payout failed
WebhookEvent::BALANCE_TRANSFERRED // 🏦 Balance transferred to bank
```

**Event Helper Methods:**

```
$event = WebhookEvent::PAYMENT_PAID;

$event->isSuccessEvent();     // true
$event->isFailureEvent();     // false
$event->isPostPaymentEvent(); // false
$event->getDescription();     // "Payment completed successfully"
```

### 🛠️ Management Commands (Laravel)

[](#️-management-commands-laravel)

**List &amp; View Webhooks:**

```
# List all webhooks with summary
php artisan moyasar:webhook list

# Show detailed webhook information
php artisan moyasar:webhook show webhook_abc123

# Delete webhook with confirmation
php artisan moyasar:webhook delete webhook_abc123
```

**Debug Delivery Attempts:**

```
# List all delivery attempts
php artisan moyasar:webhook-attempts list

# Show only failed delivery attempts
php artisan moyasar:webhook-attempts list --failed

# Filter by specific webhook
php artisan moyasar:webhook-attempts list --webhook=webhook_abc123

# View detailed attempt information
php artisan moyasar:webhook-attempts show attempt_abc123
```

**Command Features:**

- 📊 **Rich Tables** - Formatted output with status indicators
- 🔍 **Detailed Views** - Full attempt details including headers/body
- ⚡ **Smart Filtering** - Filter by webhook ID, failed attempts only
- 📈 **Statistics** - Success/failure counts and summaries

---

💰 Settlement API
----------------

[](#-settlement-api)

Track and manage your settlement data with comprehensive settlement operations.

### 📋 List Settlements

[](#-list-settlements)

```
use FateelTech\Moyasar\Laravel\Facades\Moyasar;

// List all settlements
$settlements = Moyasar::settlements()->list();

// List with pagination and filters
$settlements = Moyasar::settlements()->list(
    page: 2,
    id: 'settlement_abc123',
    createdGt: '2024-01-01',
    createdLt: '2024-12-31'
);

// Access settlement data
foreach ($settlements->items as $settlement) {
    echo "Settlement ID: " . $settlement->id . "\n";
    echo "Amount: " . $settlement->amount . " " . $settlement->currency->value . "\n";
    echo "Fee: " . $settlement->fee . "\n";
    echo "Net Amount: " . $settlement->getNetAmount() . "\n";

    if ($settlement->hasInvoice()) {
        echo "Invoice URL: " . $settlement->invoiceUrl . "\n";
    }
}
```

### 🔍 Find Settlement

[](#-find-settlement)

```
// Find specific settlement
$settlement = Moyasar::settlements()->find('settlement_abc123');

echo "Recipient Type: " . $settlement->recipientType . "\n";
echo "Settlement Count: " . $settlement->settlementCount . "\n";
echo "Created: " . $settlement->createdAt->format('Y-m-d H:i:s') . "\n";
```

### 📊 Settlement Lines (Fluent API)

[](#-settlement-lines-fluent-api)

```
// Find settlement and get its lines in one fluent chain
$settlement = Moyasar::settlements()->find('settlement_abc123');
$lines = $settlement->getLines();

// Or with pagination
$lines = $settlement->getLines(page: 2);

// Access line data
foreach ($lines->items as $line) {
    echo "Payment ID: " . $line->paymentId . "\n";
    echo "Type: " . $line->type . "\n";
    echo "Amount: " . $line->amount . " " . $line->currency->value . "\n";
    echo "Fee: " . $line->fee . "\n";
    echo "Net Amount: " . $line->getNetAmount() . "\n";

    if ($line->hasMetadata()) {
        echo "Metadata: " . json_encode($line->metadata) . "\n";
    }

    if ($line->source) {
        echo "Payment Source: " . $line->source->type->value . "\n";
    }
}
```

### 📄 Direct Settlement Lines Access

[](#-direct-settlement-lines-access)

```
// Alternative: Direct access to settlement lines
$lines = Moyasar::settlements()->listLines('settlement_abc123');

// With pagination
$lines = Moyasar::settlements()->listLines('settlement_abc123', page: 2);
```

### 🔧 Settlement Helper Methods

[](#-settlement-helper-methods)

```
$settlement = Moyasar::settlements()->find('settlement_abc123');

// Check available resources
if ($settlement->hasInvoice()) {
    $invoiceUrl = $settlement->invoiceUrl;
}

if ($settlement->hasCsvList()) {
    $csvUrl = $settlement->csvListUrl;
}

if ($settlement->hasPdfList()) {
    $pdfUrl = $settlement->pdfListUrl;
}

// Calculate net amount after fees and taxes
$netAmount = $settlement->getNetAmount();
```

---

💼 Real-World Examples
---------------------

[](#-real-world-examples)

### E-commerce Payment

[](#e-commerce-payment)

Include order metadata for seamless tracking:

```
$payment = $moyasar->payments()->createWithToken(
    token: $request->payment_token,
    amount: $order->total_in_halalas,
    description: "Order #{$order->id}",
    metadata: ['order_id' => $order->id]
);
```

### Subscription Billing

[](#subscription-billing)

Monthly billing job example:

```
class ProcessSubscriptionBilling implements ShouldQueue
{
    public function handle(MoyasarClient $moyasar)
    {
        Subscription::due()->chunk(100, function ($subscriptions) use ($moyasar) {
            foreach ($subscriptions as $subscription) {
                $moyasar->payments()->createWithToken(
                    token: $subscription->payment_token,
                    amount: $subscription->plan->price,
                    metadata: ['subscription_id' => $subscription->id]
                );
            }
        });
    }
}
```

---

⚠️ Apple Pay Notice
-------------------

[](#️-apple-pay-notice)

Apple Pay failures trigger `on_completed` but NOT `callback_url`.

**Recommendation:** Always verify Apple Pay payment status on your server immediately upon completion.

---

📄 License
---------

[](#-license)

MIT License

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance64

Regular maintenance activity

Popularity18

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity45

Maturing project, gaining track record

 Bus Factor1

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

Every ~17 days

Total

2

Last Release

221d ago

### Community

Maintainers

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

---

Top Contributors

[![farishrf](https://avatars.githubusercontent.com/u/23425456?v=4)](https://github.com/farishrf "farishrf (14 commits)")

---

Tags

phplaravelpaymentgatewayfintechsaudi-arabiaMoyasarfateel

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/fateel-tech-moyasar-php/health.svg)

```
[![Health](https://phpackages.com/badges/fateel-tech-moyasar-php/health.svg)](https://phpackages.com/packages/fateel-tech-moyasar-php)
```

###  Alternatives

[sebdesign/laravel-viva-payments

A Laravel package for integrating the Viva Payments gateway

4845.9k](/packages/sebdesign-laravel-viva-payments)[omalizadeh/laravel-multi-payment

A driver-based laravel package for online payments via multiple gateways

491.1k](/packages/omalizadeh-laravel-multi-payment)[baklysystems/laravel-paymob

Laravel PayMob online payment gateway package

282.4k](/packages/baklysystems-laravel-paymob)

PHPackages © 2026

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