ferus / fairpay-php-sdk
There is no license information available for the latest version (dev-master) of this package.
PHP DSK to work with FairPay
dev-master
2014-10-30 12:34 UTC
Requires
- php: >=5.2.0
- ext-curl: *
- ext-json: *
This package is not auto-updated.
Last update: 2025-01-14 04:49:58 UTC
README
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 }