1. Go to this page and download the library: Download barkapay/payhub-php 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/ */
barkapay / payhub-php example snippets
use PayHub\Client;
$payhub = new Client(
apiKey: 'pk_live_xxx:sk_live_yyy', // the "key_id:secret" you copy from the dashboard
country: 'bf', // default country, overridable per call
);
$payment = $payhub->payments->create([
'operator' => 'ORANGE',
'phone_number' => '50123456789',
'amount' => 10000,
'otp' => '123456', // only for synchronous-OTP operators (e.g. Orange)
'order' => ['id' => 'ORDER-2026-001'],
]);
echo $payment->publicId, ' ', $payment->status?->value;
$payhub->payments->create([...]); // returns PayHub\DTO\Payment
$payhub->payments->get('pay_… or order_id'); // by public_id or your order_id
$payhub->payments->list(['status' => 'SUCCESSFUL', 'per_page' => 50]); // PaymentCollection
$payhub->payments->confirmOtp($publicId, '123456'); // for AWAITING_OTP payments
$payhub->payments->resendOtp($publicId);
$balance = $payhub->balance->get(); // PayHub\DTO\Balance: available / total / holds / currency
$payhub->operators->info(); // authoritative operator list for the country
$payhub->operators->availability();
$payhub->me();
use PayHub\Webhook;
use PayHub\Exception\SignatureVerificationException;
try {
$event = Webhook::parse(
$rawBody,
$_SERVER['HTTP_PAYHUB_SIGNATURE'] ?? '',
$endpointSecret, // whsec_…
);
} catch (SignatureVerificationException) {
http_response_code(400);
exit;
}
// No `event` field — derive it from $event['type'] + $event['status'].
// Deduplicate on $event['public_id'] (retries deliver the same body).