此包已被弃用且不再维护。没有建议的替代包。

对 Fio API 的基本操作。

v1.0.0 2016-03-30 11:53 UTC

This package is auto-updated.

Last update: 2022-10-04 10:17:24 UTC


README

提供使用 Fio API 进行基本操作的库。

安装

$ composer require lightools/fio

使用方法

此库不实现 Fio API 的所有功能(例如欧元或国际支付),它只为最常见的用例提供简单的接口。您可以轻松地处理多个 Fio 账户,或者可以直接使用 FioClient。

初始化

$httpClient = new Bitbang\Http\Clients\CurlClient();
$xmlLoader = new Lightools\Xml\XmlLoader();

$fio = new Lightools\Fio\FioClient($xmlLoader, $httpClient);
$account = new Lightools\Fio\FioAccount('12345678', 'token', $fio); // no problem with having more Fio accounts

检索新支付

try {
    $transactions = $account->getNewTransactions();
    foreach ($transactions as $transaction) {
        echo $transaction->getVariableSymbol();
    }

} catch (Lightools\Fio\FioException $e) { // or catch specific exceptions
    $account->setBreakpointById($lastKnownMoveId);
    // further processing
}

发送交易订单

try {
    $amount = 100;
    $currency = 'CZK';
    $accountTo = '12345678';
    $bankCode = '6100';
    $order = new Lightools\Fio\TransactionOrder($amount, $currency, $accountTo, $bankCode);
    $order->setVariableSymbol('8888');

    $account->sendOrders([$order]);

} catch (Lightools\Fio\FioTemporaryUnavailableException $e) {
    // Fio is overheated, wait 30 seconds and repeat

} catch (Lightools\Fio\FioWarningException $e) {
    // in this case, Fio accepted orders, but detected something suspicious

} catch (Lightools\Fio\FioFailureException $e) {
    // e.g. HTTP request failed, Fio is down, ...
}

记录流量

当与 Fio API 通信时,存储 HTTP 请求和响应非常有用,这样您可以轻松地确定所有可能的问题。库 lightools/bitbang-http-logger 提供此功能。

如何运行测试

$ vendor/bin/tester -c tests/php.ini -d extension_dir=ext tests