Search by

selapay / sela-php

Fayyal

Sela Pay PHP library — payments and webhook verification

v1.1.0 2026-12-03 15:33 UTC

This package is auto-updated.

Last update: 2026-12-03 15:58:23 UTC


README

One file, no dependencies besides cURL. PHP 7.2+.

Docs: https://pay.selapay.ly/docs

Install

composer require selapay/sela-php

Or copy Sela.php into your project and require it.

Create a payment

$sela = new Sela('sl_test_…');   // sl_live_… for real payments

$payment = $sela->createCheckout([
    'amount'     => '100.00',
    'reference'  => 'ORDER_12345',
    'return_url' => 'https://shop.example.ly/thanks',
], 'ORDER_12345');               // Idempotency-Key

header('Location: ' . $payment['url']);

Confirm it

At your webhook URL:

try {
    $event = Sela::webhook($webhookSecret);   // verifies signature and freshness
} catch (SelaException $e) {
    http_response_code(401);
    exit;
}

if ($event['event'] === 'payment.success') {
    $payment = $sela->getPayment($event['trx_ref']);   // source of truth
    // match $payment['amount'] and $payment['reference'] with your order, then fulfil it
}
http_response_code(200);

Errors

Failed requests throw SelaException: $e->errorCode is the error name (for example INVALID_INPUTS), $e->getCode() the HTTP status, and $e->fields the field errors.

Keep the token on your server

The access token is secret. Never put it in a web page or a mobile app.

العربية: https://pay.selapay.ly/docs/resources/sdks