chalcedonyt / laravel-cos-processor
Provides functionality to upload COS (Cheque Outsourcing Services) files.
Installs: 2 137
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 1
Open Issues: 0
Requires
- php: ~5.5|~7.0
- illuminate/support: ~5.1
Requires (Dev)
- fzaninotto/faker: ~1.4
- illuminate/database: ~5.1
- illuminate/filesystem: ~5.1
- orchestra/testbench: ~3.0
- phpunit/phpunit: ~4.0||~5.0
- scrutinizer/ocular: ~1.1
- squizlabs/php_codesniffer: ~2.3
This package is not auto-updated.
Last update: 2024-11-09 20:39:24 UTC
README
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.
Install
Via Composer
$ composer require chalcedonyt/laravel-cos-processor
Creating an Adapter
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.
Configuration
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.
Usage - Generating a file to upload
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;
Usage - Processing a result file from HSBC
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);
License
The MIT License (MIT). Please see License File for more information.