Skip to content

Flow Name: [I2C] Auto-Deactivate PAC Subscription on Order Stopped

Last Updated: 2025-07-01 Source Code: I2C_Auto_Deactivate_PAC_Subscription_on_Order_Stopped.flow-meta.xml

API Name: I2C_Auto_Deactivate_PAC_Subscription_on_Order_Stopped Status: Active Type: Custom Trigger: ChargentOrder update (async after commit) when payment status changes to "Stopped"

Business Purpose

Automatically deactivates active PAC contribution subscriptions when the associated ChargentOrder's payment status is changed to "Stopped", ensuring subscription records accurately reflect the billing status.

Process Flow

  1. PAC Product Lookup: Retrieves all PAC contribution products using hardcoded SKU codes
  2. Product ID Collection: Transforms product records into collection of product IDs
  3. Active Subscription Search: Finds active subscriptions linked to the ChargentOrder with PAC products
  4. Subscription Deactivation: Updates subscription status from "Active" to "Expired"
  5. Error Handling: Displays custom error message if subscription update fails
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: ChargentOrder update (async after commit) when payment status changes to "Stopped"]) --> Lookup[Lookup Related Data]

    Lookup --> Found{Data<br/>Found?}
    Found -->|No| End([End])
    Found -->|Yes| Calculate[Calculate/Determine Values]

    Calculate --> Update[Update Records]
    Update --> End

    style Start fill:#e1f5ff
    style Lookup fill:#f0e1ff
    style Found fill:#fff4e1
    style Calculate fill:#e1ffe1
    style Update fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Only processes ChargentOrders when payment status changes to "Stopped"
  • Uses async processing for performance optimization
  • Targets PAC products with specific SKU codes: P-PAC-998, P-PAC-997, P-PAC-032
  • Only affects subscriptions with "Active" status
  • Changes subscription status to "Expired" rather than "Inactive"

Dependencies

  • ChargentOrders__ChargentOrder__c with ChargentOrders__Payment_Status__c field
  • Product2 with PAC contribution SKU codes
  • Subscription__c with Status__c, Chargent_Order__c, and Product__c fields
  • Proper relationships between ChargentOrder and Subscription objects

Changes

No specific change references noted in the flow.

⚠️ Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • Hardcoded values that should be configurable: PAC product SKU codes "P-PAC-998", "P-PAC-997", "P-PAC-032" are hardcoded
  • Missing null checks on required operations: No validation that PAC products are found before processing

HIGH - Address Soon After Go-Live

  • Missing error handling or fault paths: No error handling for Product lookup failures or empty product collections
  • Single subscription retrieval assumes only one active subscription per ChargentOrder/Product combination
  • No validation that ChargentOrder is actually for PAC contributions before processing

MEDIUM - Future Enhancement

  • Replace hardcoded SKU codes with custom metadata or settings
  • Add validation that subscription update was successful
  • Add logging for subscription deactivation events
  • Consider bulk processing for multiple subscriptions if needed

LOW - Monitor

  • Monitor for subscription deactivation failures
  • Validate that only PAC subscriptions are affected
  • Track correlation between stopped orders and deactivated subscriptions

Maintenance Notes

Simple, focused flow with clear business purpose. Moderate complexity due to hardcoded values and transform operations. Important for PAC contribution lifecycle management. Should externalize hardcoded SKU codes for better maintainability and add basic validation.