Skip to content
PHP DSK for FairPay
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
src/Ferus/FairPayApi
.gitattributes
.gitignore
composer.json
readme.md

readme.md

PHP SDK for FairPay

Instalation

Avec Composer

Ajoutez cette ligne à votre composer.json

{
    "require": {
        "ferus/fairpay-php-sdk": "dev-master"
    }
}

Puis lancez la commande suivante :

php composer.phar update

A la main

Copiez le contenue du dossier src dans votre projet.

Utilisation

require_once __DIR__ . '/vendor/autoload.php'; // pour une instalation avec composer
require_once __DIR__ . '/Ferus/FairPayApi/FairPay.php'; // pour une instalation manuelle

use Ferus\FairPayApi\FairPay;

$fairpay = new FairPay();
$fairpay = new FairPay('api_s3cr3t');

$fairpay->setApiKey('api_s3cr3t');
$fairpay->setEndpoint('http://localhost/perso/api');

$fairpay->api('/students');
$fairpay->api('/students/{query}', 'get', array('query' => $query));

// Racourcis
$fairpay->getStudents();
$fairpay->getStudent($query);
$fairpay->searchStudents($query);
$fairpay->getBalance();
$fairpay->cash($client_id, $amount, $cause);
$fairpay->deposit($client_id, $amount);

Gestion des erreurs

use \Ferus\FairPayApi\Exception\CurlExecException;
use \Ferus\FairPayApi\Exception\ApiErrorException;

try{
    $fairpay->cash($client_id, $amount, $cause);
}
catch(CurlExecException $e){
    $e->message; // curl error message
}
catch(ApiErrorException $e){
    $e->message; // api error message
    $e->code; // http status code
    $e->returned_value; // full api responce
}
You can’t perform that action at this time.