1. Go to this page and download the library: Download cinetpay-dev/cinetpay-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/ */
$confirmed = $cinetpay->webhooks()->handlePayment(
payload: $requestBody, // Tableau associatif ou corps JSON brut
expectedNotifyToken: $notifyTokenStoredAtInitialization,
);
if ($confirmed->isSuccessful()) {
// Le statut SUCCESS vient de l'API CinetPay, jamais du webhook.
}
$confirmed = $cinetpay->webhooks()->handleTransfer(
payload: $requestBody,
expectedNotifyToken: $notifyTokenStoredAtInitialization,
);
if ($confirmed->isFinal()) {
// SUCCESS, FAILED ou autre statut final documenté.
}
use CinetPay\Exception\ApiException;
use CinetPay\Exception\AuthenticationException;
use CinetPay\Exception\TransportException;
use CinetPay\Exception\ValidationException;
try {
$balance = $cinetpay->balances()->get();
} catch (AuthenticationException $exception) {
// Identifiants invalides ou jeton refusé après renouvellement.
} catch (ValidationException $exception) {
// HTTP 422 : $exception->apiCode, apiStatus et response sont disponibles.
} catch (TransportException $exception) {
// Timeout, DNS ou erreur réseau.
} catch (ApiException $exception) {
// Autre erreur HTTP/API.
}
interface TokenStore
{
public function get(string $accountKey): ?AccessToken;
public function put(string $accountKey, AccessToken $token): void;
public function forget(string $accountKey): void;
}
bash
composer
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.