Cert++
Close

Registering a custom Apex integration and mapping it to a store

Key Takeaway

After you write the Apex class, register it in RegisteredExternalService, then map that registration to a store in StoreIntegratedService.

A custom Apex integration lets a B2B store use your own code for a checkout calculation, such as price, inventory, shipping, or tax. Writing the Apex class is only the first step. Think of the next two steps this way: registration says what the class does, and mapping says which store uses it.

How to set up a custom Apex integration

An integration's Apex class implements one of four interfaces. The table pairs each interface with its ExternalServiceProviderType value and an example DeveloperName. You configure one provider for each type.

InterfaceExternalServiceProviderTypeExample DeveloperName
sfdc_checkout.CartInventoryValidationInventoryCHECK_INVENTORY
sfdc_checkout.CartPriceCalculationsPriceCOMPUTE_PRICE
sfdc_checkout.CartShippingChargesShipmentCOMPUTE_SHIPPING
sfdc_checkout.CartTaxCalculationsTaxCOMPUTE_TAXES
  1. Create an Apex class that implements the interface for your calculation.
  2. Register the class by inserting a RegisteredExternalService record. Its key fields are:
    • ExternalServiceProviderId: the Id of the Apex class
    • ExternalServiceProviderType: the kind of provider, which is the value paired with the class's interface
    • DeveloperName
    • MasterLabel
  3. Map the registration to a store by inserting a StoreIntegratedService record. Its three required fields are:
    • Integration: the RegisteredExternalService Id or [ServiceProviderType]__[DeveloperName], joined with two underscores, such as Price__COMPUTE_PRICE
    • ServiceProviderType: a value that must match ExternalServiceProviderType on the RegisteredExternalService record
    • StoreId: the Id of the WebStore

Ana has an Apex class that implements sfdc_checkout.CartShippingCharges, and she wants one store to use it. She registers the class with its Id in ExternalServiceProviderId, Shipment in ExternalServiceProviderType, and COMPUTE_SHIPPING in DeveloperName. She then inserts a StoreIntegratedService record with Shipment in ServiceProviderType, her WebStore Id in StoreId, and the new RegisteredExternalService Id in Integration. The value Shipment__COMPUTE_SHIPPING would also work in Integration.

Salesforce Accredited B2B Commerce Developer Professional Study Guide

Checklist progress

0/124Learned

Manage data intelligently with regard to relationships and integrations as needed to support getting a B2B Storefront established and running

0/29

Product bundles versus product sets

Learn this concept

Tiered and volume pricing data model

Learn this concept

WebCart and its related cart objects

Learn this concept

Prepare for the Exam

Play Today's Certle

Study Community

Ask questions and get the latest info from other Salesforce Accredited B2B Commerce Developer Professional studiers.