anam/aba

提供了一种简单的方法来生成ABA文件,这种文件被银行用来进行批量交易。

v1.0.1 2016-08-16 02:47 UTC

This package is not auto-updated.

Last update: 2024-09-14 19:04:12 UTC


README

提供了一种简单的方法来生成ABA文件,这种文件被银行用来进行批量交易。

特性

  • 简单的API
  • 框架无关

要求

  • PHP 5.4+

安装

Aba 通过 Composer 可用

$ composer require anam/aba

集成

Laravel 集成

虽然 Aba 是框架无关的,但它默认支持 Laravel,并提供了一个 Service provider 和 Facade 以便于集成。

安装 Aba 后,打开 Laravel 包含的 config/app.php 文件,并添加以下行。

$providers 数组中添加以下服务提供者。

Anam\Aba\AbaServiceProvider::class

将此包的 facade 添加到 $aliases 数组中。

'Aba' => Anam\Aba\Facades\Aba::class,

现在您可以在以下示例中使用此 facade 来代替自己实例化转换器。

用法

use Anam\Aba\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();

附录

验证
交易代码

参考