peyemapi / sdk
PHP SDK for PeyemAPI - Haitian payment gateway
dev-master
2026-03-30 17:46 UTC
Requires
- php: >=8.1
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2026-04-30 18:14:20 UTC
README
A modern, PSR-4 compliant PHP SDK for integrating PeyemAPI payments.
Installation
Install via Composer:
composer require peyemapi/sdk
(Note: Ensure you have Guzzle installed or a compatible PSR-18 client.)
Usage
Initialize the Client
use Peyem\Sdk\Client; $client = new Client('your_secret_key'); // Optional: Override API URL (can also be set via PEYEM_API_URL env var) // $client = new Client('your_secret_key', 'https://custom-api.com');
Create a Payment
try { $response = $client->createPayment([ 'amount' => 500, // HTG 'referenceId' => 'ORDER-123', 'returnUrl' => 'https://example.com/return', 'description' => 'Optional description' ]); if (!empty($response['payment_url'])) { header('Location: ' . $response['payment_url']); exit; } } catch (\Peyem\Sdk\Exceptions\PeyemException $e) { echo "Error: " . $e->getMessage(); }
Check Payment Status
$status = $client->checkStatus('ORDER-123'); echo "Status: " . $status['status'];
Get Account Balance
$balance = $client->getBalance(); echo "Balance: " . $balance['balance'] . " " . $balance['currency'];
Webhook Verification
Verify incoming webhooks from PeyemAPI:
$payload = file_get_contents('php://input'); $signature = $_SERVER['HTTP_X_WEBHOOK_SIGNATURE'] ?? ''; $webhookSecret = 'whsec_...'; if (\Peyem\Sdk\Client::verifyWebhookSignature($payload, $signature, $webhookSecret)) { // Valid webhook }
Running Tests
To run the test suite:
composer install vendor/bin/phpunit
License
MIT