PHP code example of nacha / file-generator
1. Go to this page and download the library: Download nacha/file-generator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nacha / file-generator example snippets
use Nacha\File;
use Nacha\Batch;
use Nacha\Record\DebitEntry;
use Nacha\Record\CcdEntry;
// Create the file and set the proper header info
$file = new File();
$file->setImmediateDestination('051000033')
...
->setReferenceCode('MYCODE');
// Create a batch and add some entries
$batch = new Batch();
$batch->getHeader()
...
->setOriginatingDFiId('01021234');
$batch->addDebitEntry((new DebitEntry)
...
->setTraceNumber('99936340', 1));
$file->addBatch($batch);
// completed file ready for output
$output = (string)$file;