PHP code example of qattapay / laravel

1. Go to this page and download the library: Download qattapay/laravel 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/ */

    

qattapay / laravel example snippets


use QattaPay\Laravel\Facades\QattaPay;

Route::post('/qattapay/intent', function () {
    $result = QattaPay::intents()->create([
        'itemSnapshot' => [
            [
                'name' => 'Luxury Watch',
                'price' => 150000,
                'reference' => 'watch-001',
            ],
        ],
        'totalAmount' => 150000,
        'currency' => 'SAR',
        'metadata' => ['cart_id' => 'abc'],
    ]);

    return [
        'intentId' => $result['intent']['id'],
    ];
})->middleware('web')->name('qattapay.intent');

use Illuminate\Http\Request;
use QattaPay\Laravel\Facades\QattaPay;

Route::post('/webhooks/qattapay', function (Request $request) {
    $event = $request->attributes->get('qattapay_event');

    if ($event['type'] === 'order.funded') {
        $orderId = $event['payload']['order_id'] ?? null;
        if ($orderId) {
            QattaPay::orders()->fulfill($orderId);
        }
    }

    return response()->noContent();
})->middleware('qattapay.webhook');

QattaPay::intents()->create([/* ... */]);
QattaPay::intents()->get($intentId);

// List all orders
QattaPay::orders()->list();

// Get detail (ulfilling
QattaPay::orders()->fulfill($orderId);

// fulfilling → delivered
QattaPay::orders()->deliver($orderId);

// Refund every captured contribution (blocked once the order is in a payout)
QattaPay::orders()->refund($orderId, ['reason' => 'Out of stock']);

// Refund a single contributor
QattaPay::orders()->refundContribution($orderId, $contributionId, [
    'reason' => 'Contributor requested to back out',
]);

QattaPay::webhooks()->verifySignature($rawBody, $signature);
QattaPay::webhooks()->constructEvent($rawBody, $signature);
bash
php artisan vendor:publish --tag=qattapay-config