bensondevs / laravel-mayar
Laravel integration for the Mayar Headless API.
Requires
- php: ^8.3
- bensondevs/supercharged-enums: ^0.1.0
- illuminate/contracts: ^10.0|^11.0|^12.0|^13.0
- illuminate/http: ^10.0|^11.0|^12.0|^13.0
- illuminate/pagination: ^10.0|^11.0|^12.0|^13.0
- illuminate/support: ^10.0|^11.0|^12.0|^13.0
- illuminate/validation: ^10.0|^11.0|^12.0|^13.0
Requires (Dev)
- laravel/pint: ^1.29
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^4.0
- pestphp/pest-plugin-laravel: ^4.0
- phpunit/phpunit: ^12.0
README
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