The easiest way to set up recurring payments is to use Chargent’s Payment Console. It is available on any page that includes Chargent Anywhere and allows you to process one-time payments and set up recurring payments directly from a Salesforce popup window. This makes it a convenient interface for call center agents, customer service, billing, or sales teams since it is able to initiate payments, receive tokens back from the payment gateway, and create transaction records associated with orders in Salesforce.
Most importantly, the Payment Console creates transactions and tokens without ever saving or storing cardholder account number information in Salesforce. Plus, you can set up recurring payments from any object where you have Chargent Anywhere.
Before You Begin #
Make sure your gateway is configured to allow recurring payments. Check the gateway setup guide to ensure you have selected the Show Setup Recurring Button for your gateway.
You must also set up a Recurring Billing Batch. This is typically created automatically the first time you run Chargent’s Setup Wizard. For more information, visit the Recurring Billing Batch section of this page.
Creating Recurring Payments #
- To initiate a recurring payment for a record, open that record. This record can be on any object you have Chargent Anywhere configured. For example, select Chargent from the App Launcher and choose the Chargent Orders tab and create a new order or select an existing order.
- Click Payment Console. Billing information displays if it is incomplete.
- Enter billing information if it is not already available and click Continue. This is required if you forgot a required field like State.
- Optionally, click Update to change billing information and Continue to return to payment details. Here, you can authorize or charge a single payment while the One Time button is highlighted.
The following options are only available if your gateway is configured for recurring payments.
- Click Recurring and enter the following values for your recurring payment:
Card | Account Holder Name, Card Number, Expiration, and CVC (if configured to accept CVC) |
Bank Account | Name on Account, Routing Number, Account Number, Bank Name, and Account Type |
Initial Amount | Enter a one-time payment amount to be charged at the onset of the series, such as a down payment. You’ll be given the option to authorize this amount before charging the transaction if your gateway has configured it. Select Authorize Only to approve this amount without processing it.Note: this field does not show up if a recurring payment has already been applied to a record without an initial amount. To reset this, delete all recurring values, including the token, and it will redisplay. |
Recurring Amount | Enter the amount to be charged repeatedly based on the recurring settings. If you change this amount, all future payments will be charged the new amount without changing previous payments.Note: when splitting payments between two parties (as in two parents who split child care payments), do not divide the recurring amount in half. Instead, create a separate recurring payment schedule for each party with a Bimonthly frequency. |
- Click Next to view recurring payment settings.
7. Enter the following settings for your series of recurring payments:
Frequency | Choose if you want this payment to recur Daily, Weekly, or Monthly. When you select any frequency besides Once, you also need to select an option in Payment Stop.Note: when splitting payments between two parties (as in two parents who split child care payments), create a separate recurring payment Chargent Order record for each party with a Bimonthly frequency. |
Payment Start Date | Enter the date you want recurring payments to begin. Without this date, no charges will be attempted. Leave this blank until you are ready for payments to begin. |
Fixed Day of Month To Charge This same field is labeled Charge Date on the Order object. | Enter the day of the month you want monthly or bimonthly charges to occur. Click here for more information on this setting. |
Balance Due Amount | Chargent calculates this field based on the Total minus the total of all past transactions, including both charges and refunds. |
Stop Rule This same field is labeled Payment Stop on the Order object. | Choose one of these options:
|
Payment End Date | If Payment Stop is set to Date, enter the final date for this recurring payment. This is ignored and set to Unending if you choose Count as the Payment Stop option. |
Number of Payments This same field is labeled Payment Count on the Order object. | Enter the total number of payments you want to recur. |
Chargent sets default values for the following fields after you begin setting up a recurring billing record in the Payment Console:
Payment Status | Select Recurring. Click here to view other status definitions. |
Payment Count | The total number of payments to be collected before a recurring payment stops. |
- Optionally, click Review to display the payment schedule or Payment Details to return to the previous page.
- Click Next to review the payment schedule.
- Verify that the frequency, amounts, and scheduled payments are correct.
- Click Charge next to the text that confirms your amounts to begin the new series of transactions.
Updating Recurring Payments #
Once you have set up recurring payments, you can make changes to amounts scheduled to payment in the future. All previous transactions will remain the same.
- To edit a recurring payment series for a record, open that record. This record can be on any object you have Chargent Anywhere configured. For example, select Chargent from the App Launcher and choose the Chargent Orders tab and create a new order or select an existing order.
- Click Payment Console.
- Optionally, click Update to change billing information and Continue to return to payment details. Here, you can authorize or charge a single payment while the One Time button is highlighted.
The following options are only available if your gateway is configured for recurring payments.
- Click Recurring and review the amount scheduled for all future payments. Make any changes to the amount you want charged for future payments in the series.
- Click Stop Recurring to discontinue the recurring payment series. Click Update Recurring to make changes to the series settings.
- Make any changes to the recurring settings.
- Click Next to review your changes.
- Click Update Recurring Billing.
Stopping Recurring Payments #
To stop a recurring payment in Chargent Anywhere:
- Click Payment Console. Billing information displays if it is incomplete.
- Click Recurring.
- Click Stop Recurring. A green confirmation image displays when your recurring payment has stopped.
Going forward, Chargent’s Recurring Billing Batch will exclude this Chargent Order record. One-time charges can still be collected, and you can also configure this record to collect recurring payments at a later time.
All the above procedures use the Payment Console because it is the quickest and easiest way to manage recurring payments. You can also complete these tasks on the Chargent Orders object itself. The Chargent Orders object stores all your payment details with links to transactions and payment requests, as well as options to void, refund, or start automated collections. Click here to read more about processing payments directly from the Chargent Orders tab.
Automation and Validation Rules #
Please be cautious if you use automation, validation rules, or required fields on Chargent Orders with recurring billing. Validation rules can prevent the Chargent Order from saving properly after a transaction occurs; because recurring transactions run in a batch, errors only display on the Apex Jobs monitoring page in Salesforce.
Certain validation rule problems can result in duplicate transactions, so please be sure to test any validation rules in Sandbox prior to deployment. Contact us for additional assistance.
Recurring Billing Declines #
If a card is declined as part of the scheduled Apex batch that runs recurring billing transactions, the payment status will be changed from “Recurring” to “Error.” If you’ve enabled the Automated Collections add-on and configured it to target this Chargent Order record, the Payment Status will update to “Automated Collection” upon a declined transaction.
If you’ve received a payment and need to manually update the Chargent Order record to resume the recurring payments:
- Add updated billing information to the record.
- Change the Payment Status back to “Recurring”.
- If you have processed a charge manually outside of the recurring billing schedule by clicking the Charge button, be sure to set the Payment Start Date ahead to the next time the record should be billed to avoid a recurring charge the next time the batch runs.
Recurring Billing Batch #
The Recurring Billing Batch allows 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.
Creating 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.
Option 1: 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.
Option 2: 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, but 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
Chargent Payment Console
What are the Different Chargent Batches?
Simple Guide to Batch Apex in Salesforce