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

# Services

> The fusionCore service classes that bundle common multi-step tasks across the Platform, Commerce, and Subscriptions packages.

fusionCore groups common multi-step tasks into **service classes**. A service bundles the code, the [event-framework](/developer-guide/event-framework) hooks it fires, and the supporting metadata behind one entry point, so callers get a single, well-defined method instead of re-implementing the steps themselves.

Before you write new logic, check whether a service method already exists for the task — or whether your new logic belongs inside an existing service rather than in a fresh class. Reaching for a service first keeps the multi-step flow (and its event hooks) consistent everywhere it runs.

For the lower-level helpers these services build on, see [Utility Functions](/developer-guide/utility-functions).

## Platform Services (`FCORE_BASE`)

The Platform services are available to every package. Reference them under the `FCORE_BASE` namespace.

| Service                                                  | Purpose                                                                                                                                  | Key entry points                                            |
| -------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------- |
| `ServiceLayer`                                           | Facade of the event framework.                                                                                                           | `fireEvent`, `registerEventHandler`, `stopPropagation`      |
| `CacheServiceWithSharing` / `CacheServiceWithoutSharing` | Per-transaction record caching.                                                                                                          | `getInstance().getById` / `getByIds`                        |
| `HighlightedFieldService`                                | Resolves a Field Set into display-ready field values for LWC/Aura. FLS-aware, supports relationship paths and multi-currency.            | `getHighlightedFields(Id recordId, String fieldSetApiName)` |
| `ConstantMdtService`                                     | Type-safe access to `Constant__mdt` configuration values.                                                                                | `getInstance().getStringValue(name)`                        |
| `OrgSettingMdtService`                                   | Org-wide settings singleton (`Org_Setting__mdt`) — trigger/validation switches and similar.                                              | `getDefault()`                                              |
| `CurrencyConfigMdtService`                               | Currency configuration lookups by ISO code (`Currency_Config__mdt`).                                                                     | `getInstance().getByIsoCode(isoCode)`                       |
| `JobRunService`                                          | Asynchronous multi-stage job execution: creates `Job_Run__c` / `Job_Run_Stage__c` records from a `Job_Group__c` and runs them via batch. | `createAndRunJob(Id jobGroupId)`                            |

`JobRunService.createAndRunJob(Id jobGroupId)` returns `List<Job_Run_Stage__c>` — the staged work it created and queued.

## Commerce Services (`FCORE_PAY`)

The Commerce services handle order, financial-event, payment, and form/table configuration flows.

| Service                                                                                     | Purpose                                                                                                                                                                                                                              |
| ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `OrderService`                                                                              | Main entry point for order flows: order creation, updates, and invoice generation.                                                                                                                                                   |
| `OrderOperationsService`                                                                    | Order financial operations: payments, refunds, invoices, write-offs, adjustments, and voids. Examples: `paySingleOrder`, `refundFinancialEventsToCash`, `generateInvoices`, `writeOffOrders`, `adjustInvoice`, `voidInvoices`.       |
| `FinancialEventService`                                                                     | Creates and updates `Financial_Event__c` records, including those driven by payment provider events.                                                                                                                                 |
| `PaymentProviderEventService`                                                               | Synchronizes `Payment_Provider_Event__c` records (for example gateway webhooks) to Financial Events.                                                                                                                                 |
| `InstallmentService`                                                                        | Installment calculation for payment plans.                                                                                                                                                                                           |
| `StatementService`                                                                          | Statement business logic for Multi Order Payments: creating a `Statement__c`, adding/removing orders, locking, and payment initialization. Examples: `createStatement`, `addOrders`, `removeOrders`, `lockStatement`, `initPayment`. |
| `OrderInvoiceAdjustmentService` / `OrderInvoiceWriteOffService` / `OrderVoidInvoiceService` | The adjustment, write-off, and void flows for invoiced orders.                                                                                                                                                                       |
| `AccountService` / `ContactService` / `OpportunityService`                                  | Record-centric helpers, for example creating Orders from Accounts, Contacts, and Opportunities.                                                                                                                                      |
| `FormConfigService`                                                                         | Field-Set-driven configuration for Lightning forms.                                                                                                                                                                                  |
| `TableService`                                                                              | Column configuration for LWC data tables.                                                                                                                                                                                            |

## Subscriptions (`FCORE_MEM`)

The Subscriptions package does not expose `*Service` classes. Its multi-step tasks live in engine classes that are invoked through [event-framework](/developer-guide/event-framework) hooks rather than called directly — see the subscription events on the Event Framework page.

* `SubscriptionRenewalEngine` — creates renewal orders from renewal paths; invoked by `GenerateRenewalOrderEH` when the `GenerateRenewalOrder` event fires.
* `ProrationPriceCalculator` / `AdvancedJoinProrationPriceCalculator` — proration pricing for mid-term subscription purchases, plugged into the Commerce `CalculatePrice` flow via the pricing engine.
* `SubscriptionTermCalculator` — calculates subscription term start and end dates.

## Services Fire Event Hooks

Package services fire [event-framework](/developer-guide/event-framework) hooks at key steps. For example, activating an order fires the `GenerateInvoice` event. Those hooks are what let other packages extend a flow — by registering an event handler — without modifying the service that fires them. When you build a new service, fire an event at the points where another package might reasonably need to add behavior, and document the event on the [Event Framework](/developer-guide/event-framework) page.
