laravel-mayar maintained by bensondevs
Laravel Mayar
Laravel integration for the Mayar Headless API.
✨ Highlights
- Laravel-friendly API client with Eloquent-like resources.
- Supports products, invoices, payment requests, installments, discounts, customers, transactions, webhooks, and reviews.
- Includes SaaS/license and credit-based workflows.
- Designed for sandbox and production modes.
📋 Table of Contents
- Requirements
- Install
- Configuration
- Quick Usage
- Features
- Full Documentation
- Laravel Boost (AI Guideline)
- Develop and Test
- License
✅ Requirements
| Requirement | Notes |
|---|---|
| PHP | 8.3+ |
| Laravel | 10–13 with matching illuminate/* components |
| Mayar account | Production or sandbox API key |
📦 Install
composer require bensondevs/laravel-mayar
Publish configuration (optional):
php artisan vendor:publish --tag=mayar-config
⚙️ Configuration
Add to your .env:
MAYAR_API_KEY=your-api-key
MAYAR_MODE=sandbox
| Variable | Description |
|---|---|
MAYAR_API_KEY |
API key from the Mayar dashboard (sandbox or production portal) |
MAYAR_MODE |
sandbox (default) or production |
Use a key issued from the portal that matches your mode.
🚀 Quick Usage
use Bensondevs\Mayar\Mayar;
use Bensondevs\Mayar\Enums\MayarMode;
use Bensondevs\Mayar\Api\Products\Product;
// Raw HTTP access (advanced)
$response = Mayar::client()->get(uri: 'customer', query: [
'page' => 1,
'pageSize' => 10,
]);
// Switch mode at runtime
Mayar::mode(MayarMode::Production);
// Eloquent-like resource usage
$products = Product::search(keyword: 'course')->paginate(page: 1, perPage: 10);
use Bensondevs\Mayar\Api\Invoices\Invoice;
$invoice = Invoice::create([
'name' => 'Customer name',
'email' => 'customer@example.com',
'mobile' => '081234567890',
'description' => 'Order notes',
'items' => [
['quantity' => 1, 'rate' => 10000, 'description' => 'Item description'],
],
]);
🧩 Features
Products: list/search/detail/close/re-open.Software License Codes: license verification for software products.SaaS Membership: verify, activate, deactivate licenses.Credit Membership: balance/history/spend/add-credit/register customer.Credit Based Product: credit usage workflows and immutable checkout.Invoices: create/edit/list/filter/detail/close/re-open.Payment Requests: create/edit/list/filter/detail/close/re-open.Installments: create and detail.Discounts: create/validate/detail.Customers: list, search by email, create, update email, portal link.Transactions: balance, unpaid list, daily stats, dynamic QR.Webhooks: history, register, test, retry.Webhook Receiver: inbound webhook controller with event-driven listener handling and DTO payload access.Reviews: paginated list.
📘 Full Documentation
Complete feature docs are available in dedicated files under docs/:
- 🛍️ Products
- 🔑 Software License Codes
- ☁️ SaaS Membership
- 💳 Credit Membership
- ⚡ Credit Based Product
- 🧾 Invoices
- 💸 Payment Requests
- 🧩 Installments
- 🏷️ Discounts
- 👤 Customers
- 📊 Transactions
- 🪝 Webhooks
Webhook docs now include a complete inbound receiver guide (optional package route or manual route registration), event-listener wiring for all documented Mayar webhook event types, and DTO-based payload handling.
🤖 Laravel Boost (AI Guideline)
This package ships a Laravel Boost third-party guideline at:
resources/boost/guidelines/core.blade.php
When this package is installed in a Laravel app that uses Boost, running php artisan boost:install (or php artisan boost:update) allows Boost-aware AI agents to load this package-specific guidance.
🧪 Develop and Test
composer install
composer test
Tests use Http::fake() and do not call the live Mayar API.
📄 License
MIT