> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fusioncore.us/llms.txt
> Use this file to discover all available pages before exploring further.

# Configuring Auto-Charge

> Schedule the daily Auto-Charge batch job, set the saved payment method on installments, and tune the metadata that controls retries and batch size. Admins only.

## 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](/end-user-guides/orders/installments/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.

<Steps>
  <Step title="Open Schedule Apex">
    In **Setup**, go to **Scheduled Jobs**, then click **Schedule Apex**.
  </Step>

  <Step title="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.

    <Frame caption="Scheduling the AutoChargeBatch class in Schedule Apex">
      <img src="https://mintcdn.com/fusionspan/dgaf-BkijdfqhSNr/images/end-user-guides/4858052682/image-20251209-202442.png?fit=max&auto=format&n=dgaf-BkijdfqhSNr&q=85&s=3307b10f0093406bc7e8067d6e1ca704" alt="Schedule Apex screen with the AutoChargeBatch class selected to run daily" width="1648" height="673" data-path="images/end-user-guides/4858052682/image-20251209-202442.png" />
    </Frame>
  </Step>

  <Step title="Save">
    Click **Save**. The job now runs every day at the time you set.
  </Step>
</Steps>

<Info>
  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.
</Info>

## 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.

<Steps>
  <Step title="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.

    <Frame caption="Adding a Wallet Item after generating installments">
      <img src="https://mintcdn.com/fusionspan/dgaf-BkijdfqhSNr/images/end-user-guides/4858052682/image-20251211-135355.png?fit=max&auto=format&n=dgaf-BkijdfqhSNr&q=85&s=9867aa61b28fcbc07b958719574535ea" alt="Manage Installments component prompting for a Wallet Item after installments are generated" width="1895" height="563" data-path="images/end-user-guides/4858052682/image-20251211-135355.png" />
    </Frame>
  </Step>

  <Step title="Add and continue">
    Click **Add & Continue**. The installments now have a payment method set for Auto-Charge.

    <Frame caption="Installments confirmed with a saved payment method">
      <img src="https://mintcdn.com/fusionspan/dgaf-BkijdfqhSNr/images/end-user-guides/4858052682/image-20251211-135557.png?fit=max&auto=format&n=dgaf-BkijdfqhSNr&q=85&s=b9934d81ffd3584e0d5a858a4afd43b7" alt="Confirmation that the installments have a payment method set" width="1893" height="468" data-path="images/end-user-guides/4858052682/image-20251211-135557.png" />
    </Frame>
  </Step>
</Steps>

<Info>
  See [Creating Installments](/end-user-guides/orders/installments/creating-installments) for the full procedure on setting up an installment.
</Info>

## 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`).

<Warning>
  **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.
</Warning>

To enable automatic charging on renewals, open the Order Product line and check **Auto-Charging**.

<Frame caption="The Auto-Charging checkbox on an Order Product line">
  <img src="https://mintcdn.com/fusionspan/dgaf-BkijdfqhSNr/images/end-user-guides/4858052682/image-20260115-184704.png?fit=max&auto=format&n=dgaf-BkijdfqhSNr&q=85&s=53f9df9306be7e9b0f300d6381619dd6" alt="Order Product line with the Auto-Charging checkbox" width="926" height="261" data-path="images/end-user-guides/4858052682/image-20260115-184704.png" />
</Frame>

## 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.

| Setting                          | Constant record                 | What it controls                                                                               | Type   | Shipped value                                              |
| -------------------------------- | ------------------------------- | ---------------------------------------------------------------------------------------------- | ------ | ---------------------------------------------------------- |
| Max No. Of Charge Retries        | `FC_Max_No_Of_Charge_Retries`   | The number of times a failed installment charge is retried before the batch stops retrying it. | Number | `3` (missing record falls back to `0` — see warning below) |
| Cadence Of Charge Retries (days) | `FC_Cadence_Of_Charge_Retries`  | The number of days to wait between retry attempts for a failed charge.                         | Number | `1`                                                        |
| Auto Charge Batch Job Size       | `FC_Auto_Charge_Batch_Job_Size` | The number of records processed per chunk in the Auto-Charge batch job.                        | Number | `50`                                                       |

<Warning>
  **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.
</Warning>

## 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.

{/* Source: https://fusionspan.atlassian.net/wiki/spaces/fcdocs/pages/5009309702/Auto-Charge+Metadata+Settings */}
