Tutorial: Send a Batch with ACHeck21 Java API

Ryan Ackley -

Before getting started with this tutorial, make sure you have installed the ACHeck21 Java API. 

Once you have the Java API installed, you need to import the main ACHeck21 API class at the top of the file you plan on using it from

 import com.acheck21.java.ACHeck21;

Constructing a Batch

The Java API provides the com.acheck21.java.Batch class for easily constructing ACHeck21 batches to be sent to the Global Gateway. The first step in using this class is constructing it with a clientID and a sequence number

String clientID = "00000000000"; // this is not a real client id
String sequenceNumber = String.valueOf((int)(Math.random() * 10000000));

Batch batch = new Batch(clientID, sequenceNumber);

The sequence number must be unique across all batches for a particular clientID. In the above example, it uses a random number. This is fine for illustration purposes but in production this would eventually produce a duplicate sequence number and cause an error. 

After we have successfully created a Batch object, we can add transactions to the Batch. We do this by creating BatchTransaction objects and adding these to the Batch. The data required for creating a BatchTransaction is very similar to the data required for creating a check using the Java API 

String clientTag = String.valueOf((int)(Math.random() * 10000000));
String transitNumber = "063100277";
String ddaNumber = "12345678912345";
String checkNumber = String.valueOf(((int)(Math.random() * 10000000)));
double checkAmount = 100.12;
String individualName = "Nobody J. Smith";
String companyName = "ACME inc.";
String companyDescription = "Nuts and Bolts for everyone";

BatchTransaction transaction =
new BatchTransaction(clientTag,
EntryClass.WEB,
TransactionCode.DebitFromChecking,
transitNumber,
ddaNumber,
checkNumber,
checkAmount,
individualName,
companyName,
companyDescription,
null,
null,
null,
null,
null,
null);

batch.addTransaction(transaction);

The above example creates a WEB entry class debit transaction and adds it to the batch. This is the equivalent of creating a check. You can call addTransaction multiple times to add as many transactions to the batch as needed. The BatchTransaction source code contains documentation on the various arguments that are used to construct an object of that type.

Sending a Batch

After you have successfully created a Batch and added all of the transactions you need to be in the batch, you can send it the ACHeck21 Globabl Gateway using the Java API.

String username = "nobody@domain.com"; // this is not a real username
String password = "NotARealP@ssword"; // this is not a real password
String clientID = "00000000000"; // this is not a real client id

ACHeck21.sendBatch(username, password, clientID, batch);

 

Have more questions? Submit a request

Comments