nazmusshakib / aba-generator
提供了一种简单的方式来生成ABA文件,ABA文件是银行用于允许批量交易的工具。
dev-master
2020-10-08 17:40 UTC
Requires
- php: >=5.4.0
Requires (Dev)
- phpunit/phpunit: 5.4.*
This package is auto-updated.
Last update: 2024-09-09 03:20:42 UTC
README
提供了一种简单的方式来生成ABA文件,ABA文件是银行用于允许批量交易的工具。
信用
由于lodgement reference的字符串填充问题,这个分支是从https://github.com/anam-hossain/aba派生的。此分支将文本修正为左对齐,而不是右对齐。
功能
- 简单API
- 框架无关
要求
- PHP 5.4+
安装
Aba可以通过Composer获取。
$ composer require nazmusshakib/aba-generator
集成
Laravel集成
尽管Aba与框架无关,但它默认支持Laravel,并附带服务提供商和外观,以便于集成。
安装Aba后,打开包含在Laravel中的config/app.php文件,并添加以下行。
在$providers数组中添加以下服务提供商。
NazmusShakib\AbaGenerator\AbaServiceProvider::class
将此包的外观添加到$aliases数组中。
'Aba' => NazmusShakib\AbaGenerator\Facades\Aba::class,
您现在可以在以下示例中使用此外观来代替自己实例化转换器。
用法
use NazmusShakib\AbaGenerator\Aba; $aba = new Aba(); // Descriptive record or file header // The header information is included at the top of every ABA file // and is used to describe your bank details. $aba->addFileDetails([ 'bank_name' => 'CBA', // bank name 'user_name' => 'Your account name', // Account name 'bsb' => '062-111', // bsb with hyphen 'account_number' => '101010101', // account number 'remitter' => 'Name of remitter', // Remitter 'user_number' => '301500', // User Number (as allocated by APCA). The Commonwealth bank default is 301500 'description' => 'Payroll', // description 'process_date' => '270616' // DDMMYY - Date to be processed ]); // Add a transaction or Detail record $aba->addTransaction([ 'bsb' => '111-111', // bsb with hyphen 'account_number' => '999999999', 'account_name' => 'Jhon doe', 'reference' => 'Payroll number', 'transaction_code' => '53', 'amount' => '250.87' ]); $abaFileContent = $aba->generate(); // Generate ABA string. $aba->download();
多笔交易
$transactions = [ [ 'bsb' => '111-111', // bsb with hyphen 'account_number' => '999999999', 'account_name' => 'Jhon doe', 'reference' => 'Payroll number', 'transaction_code' => '53', 'amount' => '250.87' ], [ 'bsb' => '222-2222', // bsb with hyphen 'account_number' => '888888888', 'account_name' => 'Foo Bar', 'reference' => 'Rent', 'transaction_code' => '50', 'amount' => '300' ] ]; foreach ($transactions as $transaction) { $aba->addTransaction($transaction); } $aba->generate(); $aba->download("Multiple-transactions");
Laravel示例
use Aba; // Descriptive record or file header // The header information is included at the top of every ABA file // and is used to describe your bank details. Aba::addFileDetails([]); Aba::addTransaction([]); Aba::generate(); Aba::download();