bensondevs/laravel-mayar

Laravel integration for the Mayar Headless API.

Maintainers

Package info

github.com/bensondevs/laravel-mayar

pkg:composer/bensondevs/laravel-mayar

Statistics

Installs: 5

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-05-20 09:08 UTC

This package is auto-updated.

Last update: 2026-05-20 09:12:00 UTC


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

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/:

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