h4kuna/fio

从Fio银行通过json文件读取交易并发送支付。

v3.0.12 2024-09-02 13:35 UTC

README

Downloads this Month Latest Stable Version Coverage Status Total Downloads License

支持 Fio API. 读取通过json文件提供。

版本

这里是 变更日志

Nette框架

关注这个 扩展

通过composer安装到项目中

$ composer require h4kuna/fio

未实现

  • 5.3.1.7: STA (MT940)
  • 5.3.2: POS终端或商家支付网关的交易
  • 6.4.2: pain.008 (收款指令)
  • 仅用于读取交易的json
  • 仅用于导入的xml

如何使用

这里是 示例,通过命令行运行。此脚本需要同一目录下的account.ini文件,其外观如下。

[my-account]
account = 123456789
token = abcdefghijklmn

[wife-account]
account = 987654321
token = zyxuvtsrfd

FioFactory类帮助您创建FioPay和FioRead类的实例。

use h4kuna\Fio;

$fioFactory = new Fio\FioFactory(parse_ini_file($ini, true));

$fioRead = $fioFactory->createFioRead('my-account');
$fioPay = $fioFactory->createFioPay('wife-account');

$fioRead2 = $fioFactory->createFioRead(); // first in list is default, [my-account]

您可以使用不同的配置,但保持PHP数组的结构。

[
	'my-alias' => [
		'account' => '123456789',
		'token' => 'abcdefg'
	],
	'next-alias' => [
		'account' => '987654321',
		'token' => 'tuvwxyz'
	]
]

读取

请注意,所有如变量符号、常量符号和特定符号等项都可以有左侧的零。

读取日期之间的范围。

use h4kuna\Fio;
/* @var $fioRead Fio\FioRead */
/* @var $list Fio\Read\TransactionList */
$list = $fioRead->movements(/* $from, $to */); // default is last week

foreach ($list as $transaction) {
    /* @var $transaction Fio\Read\Transaction */
    var_dump($transaction->moveId);
    foreach ($transaction as $property => $value) {
        var_dump($property, $value);
    }
}

var_dump($list->getInfo());

您可以通过年份的ID下载交易。

use h4kuna\Fio;
/* @var $fioRead Fio\FioRead */
/* @var $list Fio\Read\TransactionList */
$list = $fioRead->movementId(2, 2015); // second transaction of year 2015

非常实用的方法,可以下载最后交易。

下载后自动设置新的断点。

use h4kuna\Fio;
/* @var $fioRead Fio\FioRead */
/* @var $list Fio\Read\TransactionList */
$list = $fioRead->lastDownload();
// same use like above
var_dump($list->getInfo()->idLastDownload);

更改您的断点。

按日期。

$fioRead->setLastDate('1986-12-30');
$list = $fioRead->lastDownload();
var_dump($list->getInfo()->idLastDownload);

按交易ID。

$fioRead->setLastId(123456789);
$list = $fioRead->lastDownload();
var_dump($list->getInfo()->idLastDownload); // 123456789

提示:您可以为自定义TransactionFactory定义并创建实例,然后将其添加到Read\Json::__construct()中。

支付(写入)

API有三种响应语言,默认设置为 cs。要更改

/* @var $fioPay h4kuna\Fio\FioPay */
$fioPay->setLanguage('en');

发送请求的方法是send,它接受,您的xml或abo文件路径或Property类的实例。

$myFile = '/path/to/my/xml/or/abo/file.xml'; // file extension is important
$fioPay->send($myFile);

对象仅支付给捷克或斯洛伐克。

/* @var $national Fio\Pay\Payment\National */
$national = $fioPay->createNational($amount, $accountTo);
$national->setVariableSymbol($vs);
/* set next payment property $national->set* */
$fioPay->send();

欧元区支付

/* @var $euro Fio\Pay\Payment\Euro */
$euro = $fioPay->createEuro($amount, $accountTo, $name);
$euro->setVariableSymbol($vs);
/* set next payment property $euro->set* */
$fioPay->send();

国际支付

/* @var $international Fio\Pay\Payment\International */
$international = $fioPay->createInternational($amount, $accountTo, $bic, $name, $street, $city, $country, $info);
$international->setRemittanceInfo2('foo');
/* set next payment property $international->set* */
$fioPay->send();

在一个请求中发送更多支付

foreach($pamentsRows as $row) {
	/* @var $national Fio\Pay\Payment\National */
	$national = $fioPay->createNational($row->amount, $row->accountTo);
	$national->setVariableSymbol($row->vs);
}
$fioPay->send();