The Recurring Billing Batch is related to Chargent’s Recurring Billing feature and will allow you to process recurring payments via a scheduled batch. You can process recurring payments on a daily, weekly, monthly, or annual basis (as well as other frequencies).
The batch will look for records that must be processed daily that fit your specific criteria.
- Does the Payment Status equal Recurring?
- What is the Payment Start Date?
- What is the Frequency?
- When was the last ‘Recurring’ transaction processed?
A Recurring transaction differs from a standard one-time transaction. A Recurring transaction is indicated on the Transaction Record with a checkbox indicating it was part of the Recurring Billing Batch.

Create the Recurring Billing Batch #
The Recurring Billing Batch is automatically created the first time you run the Setup Wizard in the Chargent app. You can also manually create the batch.
Create the Batch using the Setup Wizard
When you set up your first Payment Gateway using the Gateway Setup Wizard, you are prompted to set up Recurring Billing. This is recommended and will automatically schedule the Recurring Billing batch for you.
- Go to the App Launcher
and click the Chargent app.
- Click the Chargent Settings tab.
- Click the Setup Wizard subtab.
- Follow the instructions in the Setup Wizard, and when asked if you will be using recurring, scheduled, or installment payments, click Yes.
- When asked if you want to run the batch daily at 3 am local time, select your preference. If you click No you will be given the option to choose the time and cadence that your batch will run.
- Click Start Recurring Batch to create the Recurring Billing Batch.
Manually Create the Batch
There are a few reasons you may want to schedule the Recurring Billing Batch manually.
- Recurring Billing was previously manually scheduled, and the End Date has expired.
- The individual who originally set up Recurring Billing is no longer an Active Salesforce User.
First, if you already have a batch scheduled, you must delete the old batch before scheduling a new one.
- Click on the gear icon
and select Setup.
- Under Environments > Jobs select Scheduled Jobs.
- Click Del next to the ‘Chargent Recurring Batch’ job and select OK.
After deleting the old batch, you can schedule the new one.
- Click on the gear icon
and select Setup.
- Under Custom Code select Apex Classes.
- Click Schedule Apex.
- Enter the following field values:
- Job Name: Chargent Recurring Batch (Use this name to prevent additional batches from being created)
- Apex Class: Click on the magnifying glass and select “sheduledBatchProcessing”
- Schedule Apex Execution:
- Frequency = Weekly
- Check every day of the week so that the batch runs daily.
- Start Date = today’s date
- End Date (Important): The end date should be far into the future so the schedule doesn’t end. Once the batch ends, the recurring batch will no longer process recurring transactions. 2050 is generally a good year to use.
- Start Time: Although you can choose any time, we recommend 3:00 AM to give your team the whole day to review transactions and make any required adjustments or voids during business hours.
Note: The Apex Class name is “sheduledBatchProcessing”, using the word “scheduled” without the “c”.

Setting the Batch Chunk Size #
The Recurring Billing Batch processes recurring payments depending on the settings chosen when creating your initial Gateway, but you can customize the number of records sent per batch chunk by setting the Payment Batch Chunk Size Limit.
To set the number of records sent in a batch chunk:
- Go to the App Launcher
and click the Chargent app.
- Click the Chargent Settings tab.
- Click the Advanced Settings subtab.
- Set the Payment Batch Chunk Size Limit to your desired limit.
We recommend setting the Payment Batch Chunk Size Limit to 30. This will evaluate 30 records in each batch chunk. For example, if you have 160 records that are marked as Recurring, there might be 5 chunks of 30 records and 1 chunk with 10 records. The size of each batch chunk is automatically calculated to optimize the process.
Setting the Payment Batch Chunk Size Limit to 0 will set it to the default of 30.
Run the Recurring Billing Batch On Demand #
When testing the recurring batch job, it is often useful to run the Chargent scheduled apex for the recurring batch on demand instead of scheduling it and waiting until that time is reached.
Important: You should always wait until the batch has completed execution before executing it again. If batches overlap, duplicate transactions can occur.
- Click on the gear icon
and select Developer Console.
- In the Developer Console, go to Debug and select Open Execute Anonymous Window.
- Clear any text from the ‘Enter Apex Code’ window.
- Copy and Paste the following code snippet and click Execute.
ChargentOrders.TChargentBatchProcessing b = new ChargentOrders.TChargentBatchProcessing(); Database.executeBatch(b,10); |

Note: If your Payment Chunk Batch Size has been changed you will want to add the chunk size to the code. For example, if your Chunk Size is 2 the code should end in (b,2). You can check the Chunk Size under Chargent Settings > Advanced Settings.
After following the steps above, one Apex Job will be executed. Return to the Salesforce org and monitor the Job status, discussed in the next section.
Monitor the Recurring Billing Batch #
You can easily create a view that will help you monitor your Recurring Billing Batch. This is especially useful when troubleshooting any recurring billing errors.
- Click on the gear icon
and select Setup.
- Search the Quick Find and select Apex Jobs.
- Click Create New View
- Name the View. We suggest ‘Recurring Billing Batch’.
- Under ‘Filter By Additional Fields”
- Field = Apex Class
- Operator = equals
- Value = TChargentBatchProcessing
- Select the fields you’d like to include. We recommend including ‘Failures’, ‘Batches Run, and ‘Batches Processed’ to track errors or unexpected results.
- Choose how you’d like to give access to your view.
- Click Save.

Recurring Billing Batch Best Practices #
- We recommend scheduling your batches to run daily to ensure your records are always current. This is especially important with your recurring payments, ensuring your customers’ payments are processed when expected.
- You can schedule the batch using an API / integration user, so if your Salesforce Admin changes and a user is deactivated, the batch does not get deactivated. Log in with that user, and go through the Chargent Setup Wizard on the Chargent Setting tab.
- If you are scheduling the batch manually, set the end date 10+ years in the future.
- Run the batch at a time when no other batches will be running to prevent conflicts.
See Also
Recurring Billing
What are the Different Chargent Batches?
Simple Guide to Batch Apex in Salesforce