LostChurn Docs
Integrations

Salesforce Package

Install the LostChurn managed package to track payment recovery directly in Salesforce.

The LostChurn Salesforce managed package installs custom objects, Lightning Web Components, and a webhook handler into your Salesforce org. Your sales and success teams see recovery data on Account and Contact pages without switching tools.

What You Get

After installation, the package adds:

  • Custom Object (LostChurn_Recovery__c) -- Tracks every recovery attempt with status, amount, decline code, retry count, and timestamps.
  • Recovery Panel LWC -- A data table of recovery records that appears on Account and Contact record pages.
  • Recovery Timeline LWC -- A detailed timeline view on LostChurn_Recovery__c record pages showing each retry attempt and outcome.
  • Webhook Handler -- A REST endpoint that receives LostChurn webhooks and upserts Recovery records automatically.
  • API Client -- An Apex class that queries the LostChurn REST API for on-demand data sync.
  • Scheduled Sync -- A schedulable Apex job that syncs pending recoveries every 4 hours.
  • Connected App -- Pre-configured OAuth for secure API communication.

Prerequisites

  • A Salesforce org (Essentials, Professional, Enterprise, or Unlimited edition)
  • System Administrator profile or the "Customize Application" and "Manage Connected Apps" permissions
  • A LostChurn account with at least one active payment processor connected

LostChurn supports both Production and Sandbox Salesforce orgs. Choose your environment when connecting.

Install the Managed Package

  1. In your LostChurn dashboard, go to Settings > CRM and click Connect Salesforce.
  2. Select your environment: Production or Sandbox.
  3. You are redirected to Salesforce's OAuth login page. Sign in with your admin credentials.
  4. Review the requested permissions and click Allow.
  5. LostChurn installs the managed package in your org, which creates the custom object, LWC components, and Apex classes.
  6. You are redirected back to LostChurn with your Salesforce org ID and org name confirmed.

The following OAuth scopes are requested:

  • api -- REST API access for CRUD operations
  • refresh_token -- offline access for background sync

Set Up Named Credentials

The package uses Named Credentials to securely call the LostChurn API from Apex:

  1. In Salesforce Setup, go to Security > Named Credentials.
  2. The LostChurn Named Credential is created automatically during package installation with the endpoint https://api.lostchurn.com.
  3. Verify the credential shows "Authenticated" status.

If the credential was not created automatically:

  1. Click New Named Credential.
  2. Set Label to LostChurn and URL to https://api.lostchurn.com.
  3. Set Identity Type to "Named Principal" and Authentication Protocol to "OAuth 2.0".
  4. Enter the client credentials from your LostChurn dashboard (Settings > CRM > Salesforce > API Credentials).

Assign Permission Sets

The package includes a permission set called LostChurn_User that grants access to the custom object and LWC components.

  1. In Salesforce Setup, go to Users > Permission Sets.
  2. Click LostChurn_User.
  3. Click Manage Assignments and add the users who should see recovery data.

Without this permission set, users will not see the Recovery Panel or Timeline components on record pages.

Configure LWC Components

Recovery Panel on Account/Contact Pages

  1. Navigate to any Account or Contact record page.
  2. Click the gear icon and select Edit Page.
  3. Drag the LostChurn Recovery Panel component from the component palette onto the page layout.
  4. Click Save and Activate.

Recovery Timeline on Recovery Record Pages

  1. Navigate to any LostChurn_Recovery__c record.
  2. Click the gear icon and select Edit Page.
  3. The LostChurn Timeline component should already be present. If not, drag it onto the layout.
  4. Click Save and Activate.

Custom Object Fields

The LostChurn_Recovery__c object includes these fields:

FieldAPI NameType
Recovery IDRecovery_ID__cText (External ID)
StatusStatus__cPicklist (Started, Retrying, Recovered, Exhausted)
Decline CodeDecline_Code__cText
Decline CategoryDecline_Category__cText
Retry CountRetry_Count__cNumber
Recovered AmountRecovered_Amount__cCurrency
Started AtStarted_At__cDateTime
Completed AtCompleted_At__cDateTime
ContactContact__cLookup(Contact)
OpportunityOpportunity__cLookup(Opportunity)

What Gets Synced

LostChurn EventSalesforce Action
Recovery startedCreates LostChurn_Recovery__c record, publishes Platform Event
Retry attemptedUpdates retry count and status on Recovery record
Recovery succeededSets status to Recovered, creates Opportunity (Closed Won)
Recovery exhaustedSets status to Exhausted, creates Opportunity (Closed Lost)
Customer data updatedUpdates custom fields on Contact (MRR, churn risk, recovery count)

Platform Events (LostChurn_Recovery_Event__e) are published for each recovery event. Use these in Flows, Process Builder, or Apex triggers for custom automation.

Webhook Handler

The package includes a REST endpoint at /services/apexrest/lostchurn/webhook that receives recovery events from LostChurn. Webhook payloads are verified using HMAC-SHA256 to prevent spoofing.

The webhook handler:

  • Upserts LostChurn_Recovery__c records by Recovery_ID__c
  • Links records to Contacts by email address
  • Publishes Platform Events for downstream automation

Troubleshooting

"INVALID_SESSION_ID" error

Your Salesforce session has expired. Go to Settings > CRM > Salesforce in LostChurn and click Reconnect.

Custom object not created

  1. Go to Settings > CRM > Salesforce in LostChurn.
  2. Click Install Custom Objects.
  3. Ensure the connecting user has the "Customize Application" permission.

LWC components not visible

  • Confirm the user has the LostChurn_User permission set assigned.
  • Verify the components were added to the page layout via Lightning App Builder.

Duplicate contacts

LostChurn matches contacts by email. If you have duplicates, LostChurn updates the first match returned by Salesforce. Use Salesforce's duplicate management rules to merge duplicates.

Scheduled sync not running

  1. In Setup, go to Apex Jobs and confirm LostChurnScheduler is scheduled.
  2. If not, open the Developer Console and run:
    System.schedule('LostChurn Sync', '0 0 */4 * * ?', new LostChurnScheduler());

Disconnecting

  1. Go to Settings > CRM > Salesforce in LostChurn.
  2. Click Disconnect.
  3. Choose whether to keep or remove custom objects and fields.

Removing custom objects deletes all LostChurn_Recovery__c records in your org. This cannot be undone.

Next Steps

On this page