Package Data | |
---|---|
Maintainer Username: | chalcedonyt |
Maintainer Contact: | chalcedonyt@gmail.com (Timothy Teoh) |
Package Create Date: | 2016-07-10 |
Package Last Update: | 2016-10-31 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-15 15:08:16 |
Package Statistics | |
---|---|
Total Downloads: | 2,137 |
Monthly Downloads: | 0 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 1 |
Total Open Issues: | 0 |
Helper functions to deal with COS (Cheque Outsourcing Services). Generates files based on payment entries. UOB and HSBC supported at the moment. Look at the files under the documentation/ folder for the original documents from UOB and HSBC.
Via Composer
$ composer require chalcedonyt/laravel-cos-processor
Create an adapter that implements Chalcedonyt\\COSProcessor\\Adapter\\BeneficiaryAdapterInterface
. This should translate your model into the attributes that will be used in the COS entries. Refer to Chalcedonyt\\COSProcessor\\Adapter\\ExampleBeneficiaryAdapter
for an example.
php artisan vendor:publish
should publish a cos_processor.php
into the config folder. Edit this with the configuration options for your account. Change "beneficiary_adapter"
to the class of the adapter you created earlier.
Call the relevant COSUploadProcessorFactory subclass and pass in your data, and the config key.
$beneficiaries = TestPayment::all();
$cos = HSBCCOSUploadProcessorFactory::createCsvString($beneficiaries, 'cos_processor.hsbc_example');
echo $cos;
HSBC COS will return a csv file with the results of a COS upload. Refer to tests/ifile_result.csv
for an example. You can process this file into an array of COSResult
with the following code:
//the first line is the Header
$handle = fopen( __DIR__ ."/ifile_result.csv", "r");
$index = 0;
$results = [];
while (($line = fgets($handle)) !== false) {
if( $index++ !== 0){
$adapter = new HSBCCOSResultAdapter($line);
$results[] = $adapter -> getCosResult();
}
}
fclose($handle);
The MIT License (MIT). Please see License File for more information.