SDK PHP officiel pour l'API marchande SilyLink (checkout, charges, transfers, payouts, webhooks).

Maintainers

Package info

gitlab.com/sily-link/plugins/php

Issues

pkg:composer/silylink/php

Transparency log

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

1.0.0 2026-07-20 12:00 UTC

This package is not auto-updated.

Last update: 2026-07-21 19:30:46 UTC


README

SDK PHP officiel pour intégrer SilyLink (paiements, checkout, charges, transfers, payouts) dans une application PHP (sans framework, ou avec Symfony / Slim / Laravel, etc.).

Prérequis

  • PHP ^8.2
  • ext-json, ext-curl (via Guzzle)
  • Une application marchande SilyLink avec :
    • SLK-Api-Key (slk_test_… / slk_live_…)
    • encryption_password (secret HMAC)
    • access_code (requis pour Charges, Transfers, Payouts)

Installation

Via Packagist :

composer require silylink/php

Le package doit être publié sur Packagist et tagué (v1.0.0, etc.) pour que composer require fonctionne sans dépôt path/vcs local.

Configuration

Variables d’environnement (recommandé) :

SILYLINK_API_BASE_URL=https://api.silylink.com/api/v1
SILYLINK_API_KEY=slk_live_xxxxxxxx
SILYLINK_ENCRYPTION_PASSWORD=votre_secret_hmac
SILYLINK_ACCESS_CODE=123456
SILYLINK_HTTP_TIMEOUT=30

Ou configuration explicite :

use SilyLink\Client;

$client = new Client(
    apiBaseUrl: 'https://api.silylink.com/api/v1',
    apiKey: 'slk_live_xxxxxxxx',
    encryptionPassword: 'votre_secret_hmac',
    accessCode: '123456',
);

Depuis l’environnement :

$client = Client::fromEnv();

Démarrage rapide — Checkout

use SilyLink\Client;

$client = Client::fromEnv();

$session = $client->checkout()->create([
    'amount' => 50000, // GNF, entier
    'order_id' => 'ORD-1001',
    'description' => 'Commande #1001',
    'return_url' => 'https://monsite.com/paiement/retour',
    'cancel_url' => 'https://monsite.com/paiement/annule',
    'notify_url' => 'https://monsite.com/silylink/webhook',
    'options' => [
        'customer' => [
            'firstname' => 'Jean',
            'lastname' => 'Diallo',
            'email' => 'jean@example.com',
            'tel' => '620000000',
        ],
    ],
]);

// Rediriger le client vers $session['payment_url']
header('Location: '.$session['payment_url']);
exit;

Suivi :

$client->checkout()->session($operationId);
$client->checkout()->order('ORD-1001');
$client->account()->info();

Authentification & signature HMAC

Toutes les requêtes envoient SLK-Api-Key.

Les méthodes mutantes (POST, PUT, PATCH, DELETE) ajoutent :

SLK-HMAC-Signature: <hmac_sha256_hex>

Calcul (identique au serveur SilyLink) :

hash_hmac('sha256', $rawBody, $encryptionPassword);

Le SDK signe le corps JSON exact envoyé — ne re-sérialisez jamais le payload après signature côté custom.

Surface API

Préfixe distant : {SILYLINK_API_BASE_URL} (ex. …/api/v1).

Account

MéthodeClient
Infos marchand$client->account()->info()
Application$client->account()->application($accessCode?)
Transactions$client->account()->transactions(['per_page' => 25])

Checkout

MéthodeClient
Créer une session$client->checkout()->create($payload)
Lire par operation_id$client->checkout()->session($operationId)
Lire par order_id$client->checkout()->order($orderId)

Payload typique create :

[
    'amount' => 50000,              // requis, entier ≥ 1 (GNF)
    'order_id' => 'ORD-1001',       // optionnel
    'description' => '…',
    'fee_handling' => 'deduct',     // deduct | add
    'return_url' => 'https://…',
    'cancel_url' => 'https://…',
    'notify_url' => 'https://…',    // webhooks
    'options' => [/* customer, auto-redirect, … */],
]

Charges (Pull) — permission charge

MéthodeClient
Vérifier$client->charges()->check($payload)
Demander$client->charges()->request($payload)
Consulter$client->charges()->show($requestId)
Confirmer OTP$client->charges()->confirm($requestId, ['onetime_pin' => '1234'])

Transfers (Push) — permission transfer

MéthodeClient
Vérifier$client->transfers()->check($payload)
Demander$client->transfers()->request($payload)
Consulter$client->transfers()->show($requestId)

Payouts — permission payout

MéthodeClient
Settings$client->payouts()->settings()
Mettre à jour$client->payouts()->updateSettings($payload)
Lister demandes$client->payouts()->requests(['filter' => 'unpaid'])
Créer demande$client->payouts()->createRequest($payload)
Consulter$client->payouts()->showRequest($id)
Annuler$client->payouts()->cancelRequest($id)

access_code est lu depuis SILYLINK_ACCESS_CODE. Vous pouvez le surcharger par appel si besoin.

Webhooks

Handler PHP natif (recommandé)

use SilyLink\Webhooks\WebhookHandler;

$handler = WebhookHandler::create($apiKey, $encryptionPassword);

$handler->onCheckoutPaid = function (array $payload): void {
    // $payload['operation_id'], $payload['status'], …
};

$handler->onChargeUpdated = function (array $payload): void { /* … */ };
$handler->onTransferUpdated = function (array $payload): void { /* … */ };
$handler->onPayoutUpdated = function (array $payload): void { /* … */ };

$handler->handleFromGlobals(); // lit php://input, répond {"status":"ok"}

Voir examples/webhook.php. Compatible avec n’importe quel front controller (Symfony, Slim, Laravel via un contrôleur qui appelle handle()).

Vérification manuelle

use SilyLink\Webhooks\WebhookVerifier;

$verifier = new WebhookVerifier($apiKey, $encryptionPassword);
$payload = $verifier->verify(
    $rawBody, // corps brut — jamais un json_encode reconstruit
    $_SERVER['HTTP_SLK_API_KEY'] ?? null,
    $_SERVER['HTTP_SLK_HMAC_SIGNATURE'] ?? null,
);

Idempotence

SilyLink peut renvoyer plusieurs webhooks pour la même opération. Utilisez operation_id ou request_id comme clé d’idempotence côté métier.

Exemples rapides

Charge (Pull)

$check = $client->charges()->check([
    'amount' => 12000,
    'payment_channel' => 'orange_money',
    'account_number' => '620000000',
    'account_name' => 'Jean Diallo',
]);

$charge = $client->charges()->request([
    'amount' => 12000,
    'payment_channel' => 'orange_money',
    'account_number' => '620000000',
    'notify_url' => 'https://monsite.com/silylink/webhook',
    'order_id' => 'ORD-CHARGE-1',
]);

// Si OTP requis :
$client->charges()->confirm($charge['request_id'], [
    'onetime_pin' => '123456',
]);

Transfer (Push)

$client->transfers()->request([
    'amount' => 10000,
    'payment_channel' => 'orange_money',
    'account_number' => '620000000',
    'account_name' => 'Mohamed Diallo',
    'notify_url' => 'https://monsite.com/silylink/webhook',
]);

Payout

$client->payouts()->createRequest([
    'application_pin' => '4321',
    'payout_amount' => 100000,
    'note' => 'Versement hebdo',
]);

Gestion des erreurs

Les erreurs API sont levées sous forme d’exceptions typées (namespace SilyLink\Exceptions) :

HTTPException typique
401AuthenticationException
403ForbiddenException
404NotFoundException
409ConflictException
422ValidationException
autreSilyLinkException
try {
    $client->checkout()->create(['amount' => 50000]);
} catch (\SilyLink\Exceptions\ValidationException $e) {
    // $e->getMessage(), $e->errors()
}

Canaux de paiement

Selon le produit (charge / transfer), les canaux courants incluent notamment :

paycard, orange_money, mtn_momo, cc, kulu, soutra_money, wave, cash (transfers).

La disponibilité réelle dépend de votre compte marchand et de la configuration SilyLink.

Développement local (ce dépôt)

composer install
composer test

Lier le package dans une app de test (composer.json de l’app) :

{
  "repositories": [
    {
      "type": "path",
      "url": "../Plugins/PHP"
    }
  ],
  "require": {
    "silylink/php": "*"
  }
}
composer update silylink/php

Exemples :

php examples/checkout.php
# webhook : pointer votre serveur web vers examples/webhook.php

Laravel ?

Pour une intégration Laravel (Facade, Eloquent, route webhook), utilisez plutôt le package dédié silylink/laravel.

Licence

MIT — © SilyLink