PHP code example of bensondevs / laravel-mayar

1. Go to this page and download the library: Download bensondevs/laravel-mayar library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

bensondevs / laravel-mayar example snippets


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' => '[email protected]',
    'mobile' => '081234567890',
    'description' => 'Order notes',
    'items' => [
        ['quantity' => 1, 'rate' => 10000, 'description' => 'Item description'],
    ],
]);
bash
php artisan vendor:publish --tag=mayar-config