Provides functionality to upload COS (Cheque Outsourcing Services) files.
chalcedonyt/laravel-cos-processor is a Laravel package for provides functionality to upload cos (cheque outsourcing services) files..
It currently has 0 GitHub stars and 2.137 downloads on Packagist.
Install it with composer require chalcedonyt/laravel-cos-processor.
Discover more Laravel packages by chalcedonyt
or browse all Laravel packages to compare alternatives.
Last updated
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.