ferus/fairpay-php-sdk

此包的最新版本(dev-master)没有提供许可证信息。

PHP DSK 与 FairPay 一起工作

dev-master 2014-10-30 12:34 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:59:31 UTC


README

安装

使用 Composer

将以下行添加到您的 composer.json 中

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

然后运行以下命令

php composer.phar update

手动

src 目录的内容复制到您的项目中。

使用

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);

错误处理

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
}