Skip to main content

Overview

Auto-Charge is a daily scheduled batch job (AutoChargeBatch, job name FC: Auto Charge). Each day it finds pending installment payments due that day and charges them against the Wallet Item (the saved card or ACH bank account, FCORE_PAY__Wallet_Item__c) stored on each installment. Setting up Auto-Charge has three parts:
  1. Schedule the daily batch job (one-time, admin).
  2. Set a Wallet Item on the installments you want charged automatically.
  3. (Optional) Tune the metadata settings that control retries and batch size.

Prerequisites

  • You need a Salesforce admin (someone with access to Setup) to schedule the batch job.
  • A payment provider must be connected so that Wallet Items can be created. Wallet Items are created by the Stripe addon. Without a Wallet Item on an installment, Auto-Charge silently skips it — it never charges and never raises an error.
  • The Order must already have installments. See Creating Installments for the full procedure.

Schedule the Auto-Charge Batch Job

The batch job is what actually takes the payments. It runs once a day, by default at 4 AM, and charges every pending installment that is due that day.
1

Open Schedule Apex

In Setup, go to Scheduled Jobs, then click Schedule Apex.
2

Select the Auto-Charge class

For Apex Class, choose AutoChargeBatch. Give the job a name (for example, FC: Auto Charge) and schedule it to run every day. The default run time is 4 AM.
Schedule Apex screen with the AutoChargeBatch class selected to run daily

Scheduling the AutoChargeBatch class in Schedule Apex

3

Save

Click Save. The job now runs every day at the time you set.
When the job runs, it charges each installment Financial Event whose Financial Event Date is today, whose Is Cancelled is false, that has a Wallet Item, and whose Order is in a chargeable status. Installments that miss those conditions are skipped silently.

Set a Payment Method on Your Installments

Auto-Charge can only charge an installment that has a saved payment method. Add a Wallet Item to your installments when you create them.
1

Generate installments and add a payment method

When setting up an installment, after you click Generate Installments, add a Wallet Item (a saved card or ACH bank account) or save a new card or ACH payment method.
Manage Installments component prompting for a Wallet Item after installments are generated

Adding a Wallet Item after generating installments

2

Add and continue

Click Add & Continue. The installments now have a payment method set for Auto-Charge.
Confirmation that the installments have a payment method set

Installments confirmed with a saved payment method

See Creating Installments for the full procedure on setting up an installment.

Auto-Charging on Renewals

On each Order Product (the line item, OrderItem or OpportunityLineItem) there is an Auto-Charging checkbox (Auto_Charging__c, default unchecked). This field controls whether the product is paid automatically on renewals of that product. When the Order is activated, this value flows down to the renewal record (Purchase_Activity__c.Auto_Charge__c).
Auto-Charging governs renewals only. The Auto-Charging checkbox does not switch the daily Auto-Charge batch on or off for an Order’s installments. The daily batch keys off the installment payment records themselves (their date, status, and Wallet Item) — not this checkbox. Leaving Auto-Charging unchecked still lets the daily batch charge installments that have a Wallet Item. Use this field only to control whether the product renews with an automatic charge.
To enable automatic charging on renewals, open the Order Product line and check Auto-Charging.
Order Product line with the Auto-Charging checkbox

The Auto-Charging checkbox on an Order Product line

Metadata Settings

Auto-Charge has several metadata settings that control how the batch job behaves. They are Constant records, found in Setup under Custom Metadata Types, then Constants (FCORE_BASE__Constant__mdt). A Constant is a single configuration value the code reads at run time. You need admin access to view or edit these records. Get help from your system administrator before changing them.
Set Max No. Of Charge Retries explicitly. The org ships a FC_Max_No_Of_Charge_Retries record set to 3, but if that record is missing the code falls back to 0 (no retries) — not 3. Do not rely on the default. Confirm the record exists and set the value you want.

Limitations and Common Pitfalls

  • Charges only installments due exactly today. The batch picks up installments whose date is the current day. If a run is missed, it does not back-fill past-due installments on a later run — those installments are not retried automatically.
  • Silent skips. An installment is skipped without an error if it has no Wallet Item, is cancelled, is in the wrong Order status, does not have its price and tax calculated, or has already hit the retry cap.
  • Retry cap defaults to 0 when the record is missing. As above, the 3 you may have seen described is the shipped record, not a code default. A missing FC_Max_No_Of_Charge_Retries record means no retries.
  • Payment providers are processed sequentially. When installments span multiple payment providers, the batch processes one provider per chained run rather than all at once.
  • Hard dependency on a payment provider. Auto-Charge needs Wallet Items to charge against, and Wallet Items are created by the Stripe addon (or another payment-provider addon). Without one, installments are never charged.