1. Go to this page and download the library: Download jeremib/nacha-lib-php 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/ */
jeremib / nacha-lib-php example snippets
$nacha = new NachaFile();
$nacha->setBankRT('123456789')// Your bank's routing number
->setCompanyId('9876543210')// Usually your company Fed tax id with something the bank tells you to put on the front.
->setSettlementAccount('44444444444') // Your bank account you want the money to go into
->setFileID('9876543210')// Probably the same as your Company ID but your bank will tell you what this should be.
->setOriginatingBank('BANK ON IT')// Text name of your bank
->setFileModifier('A')// Usually just A - for the first file of the day. Change to 'B' for second file of the day and so on.
->setCompanyName('MY COMPANY')//16 chars - your company name
->setBatchInfo('Monthly Subscriptions') // Text description for the batch
->setDescription('Subscription', '05/17/2012') // Description shown on customers statements and date of invoice
->setEntryDate(date('m/d/Y')); // The day you want the payments to be processed. This example shows today.
$payment = array("AccountNumber"=>'1234567', // The customer's CRM account number (not bank account number)
"TotalAmount"=>30.00, // Amount they are paying you if it's a debit - or that you're paying them if it's a credit.
"BankAccountNumber"=>'123456789', // Customer's bank account number
"RoutingNumber"=>'987654321', // Customer's bank routing number
"FormattedName"=>'Joe Smith', // Customer's name
"AccountType"=> 'CHECKING'); // Could be 'CHECKING' or 'SAVINGS' - customer's bank account type
// Add a debit - taking money from someone and puting it in your account
if(!$nacha->addDebit($payment)){
// Error adding this debit. Must be something wrong. Check the $nacha->errorRecords.
}
// You can safely mix debits and credits in the same batch.
// Add a credit - sending your money to someone elses bank account
if(!$nacha->addCredit($payment)){
// Error adding this credit. Must be something wrong. Check the $nacha->errorRecords.
}
// Generate the NACHA file contents
try{
$nacha->generateFile();
// Put the file contents on the file system
if(!file_put_contents('./ACH_MyCompany_NACHA_file.txt', $nacha->fileContents)){
throw new Exception('Unable to save NACHA file');
}
}catch(Exception $e){
// Something went wrong with the file generation
print_r($e->getMessage());
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.