b-b3rn4rd/hack-bpay-reader

此包的最新版本(1.0.0)没有可用的许可证信息。

Hack BPAY Reader - 记账信息文件读取器

1.0.0 2014-04-24 08:50 UTC

This package is not auto-updated.

Last update: 2024-09-28 15:59:54 UTC


README

Build Status

Hack BPAY Reader 是一个用 hack 编写的实验性库。它解密和解析 BPAY 记账信息文件。

#需求

Hack BPAY Reader 需要 hhvm 版本 3 或更高版本,有效的 密码短语和已安装的 gnupg。

#安装

使用 Composer 安装 Hack BPAY Reader

{
    "require": {
        "b-b3rn4rd/hack-bpay-reader": "1.0.*"
    }
}

#使用方法

###基本使用

<?hh 

require 'vendor/autoload.php';

use BPAY\Transaction;
use BPAY\Reader;
use BPAY\Filters;

function main():void {
    // passphrase used to decrypt the BPAY files. It's important that it match the passphrase provided to the bank.
    $passphrase = 'testing';
    
    // absolute path to GnuPG binary
    $gpgbinary = '/usr/bin/gpg';
    
    // path where BPAY biller information file(s) are stored
    $filespath = '/home/bernard/gpg/*.gpg';

    $reader = new Reader($gpgbinary, $passphrase, $filespath);
    $transactions = $reader->read();


    foreach ($transactions as $transaction) {
        /* ... */
    }
}
main();

使用可选的回调

// move processed files to another folder
$processedDir = '/home/bernard/gpg/processed';
$transactions = $reader->read($filename ==> {
    rename($filename, sprintf('%s/%s', $processedDir, $filename->getFilename()));
});

使用预定义的过滤器

$filteredTransactions = (new Filters())->filterIsPayment($transactions);

可用过滤器

class Filters
{    
    /**
     * Filter transactions by customer reference number
     *
     * @param Vector<Transaction> $collection transactions collection
     * @param string $crn customer reference number 
     * @return Vector<Transaction> transactions filtered by customer reference number 
     */
    public function filterByCrn(Vector<Transaction> $collection, string $crn): Vector<Transaction>;
    
    /**
     * Filter transactions by filename
     *
     * @param Vector<Transaction> $collection transactions collection
     * @param string $filename source filename 
     * @return Vector<Transaction> transactions filtered by source filename 
     */
    public function filterByFilename(Vector<Transaction> $collection, string $filename): Vector<Transaction>;
    
    /**
     * Filter transactions by VISA card
     *
     * @param Vector<Transaction> $collection transactions collection
     * @return Vector<Transaction> transactions filtered by VISA card 
     */
    public function filterPaidByVISA(Vector<Transaction> $collection): Vector<Transaction>;

    /**
     * Filter transactions by Master Card card
     *
     * @param Vector<Transaction> $collection transactions collection
     * @return Vector<Transaction> transactions filtered by Master Card card 
     */
    public function filterPaidByMasterCard(Vector<Transaction> $collection): Vector<Transaction>;

    /**
     * Filter transactions by debit account 
     *
     * @param Vector<Transaction> $collection transactions collection
     * @return Vector<Transaction> transactions filtered by debit account 
     */
    public function filterPaidByDebitAccount(Vector<Transaction> $collection): Vector<Transaction>;

    /**
     * Filter transactions by debit account 
     *
     * @param Vector<Transaction> $collection transactions collection
     * @return Vector<Transaction> transactions filtered by debit account 
     */
    public function filterPaidByOtherCard(Vector<Transaction> $collection): Vector<Transaction>;

   /**
    * Filter transactions by payment type is payment 
    *
    * @param Vector<Transaction> $collection transactions collection
    * @return Vector<Transaction> transactions filtered by payment type is payment 
    */
    public function filterIsPayment(Vector<Transaction> $collection): Vector<Transaction>;

   /**
    * Filter transactions by payment type is reversal 
    *
    * @param Vector<Transaction> $collection transactions collection
    * @return Vector<Transaction> transactions filtered by payment type is reversal 
    */
    public function filterIsReversal(Vector<Transaction> $collection): Vector<Transaction>;

   /**
    * Filter transactions by payment type is error correction
    *
    * @param Vector<Transaction> $collection transactions collection
    * @return Vector<Transaction> transactions filtered by payment type is error correction 
    */
    public function filterIsErrorCorrection(Vector<Transaction> $collection): Vector<Transaction>;
}    

#许可证

未授权