Skip to content

Flow Name: Populate Formatted Payment Method on Order

Last Updated: 2025-10-22 Source Code: Populate_Formatted_Payment_Method_on_Order.flow-meta.xml

API Name: Populate_Formatted_Payment_Method_on_Order Status: Active Type: Custom Trigger: Record-Triggered (Chargent Transaction - After Save, Async After Commit)

Business Purpose

This flow automatically populates user-friendly payment method information on Order records when transactions are processed, displaying masked credit card details in a standardized format for easy identification while maintaining PCI compliance.

Process Flow

  1. Transaction Created/Updated: Chargent Transaction is saved with Order__c field changed
  2. Async Execution: Waits for transaction commit before processing
  3. Order Lookup: Retrieves the related standard Order via Order__c field
  4. Payment Method Formatting: Creates formatted string (e.g., "VISA**1234")
  5. Order Update: Updates Order with formatted payment method and payment date
  6. Safe Update: Uses SafeUpdateService to handle errors gracefully
📊 Click to view Process Flow Diagram
flowchart TD
    Start([Start: Transaction Saved]) --> Async[Async After Commit]
    Async --> GetOrder[Get Standard Order]

    GetOrder --> OrderFound{Order Found?}
    OrderFound -->|No| End([End])
    OrderFound -->|Yes| Format[Format Payment Method]

    Format --> Prepare[Prepare Order Update]
    Prepare --> SafeUpdate[Safe Update Service]
    SafeUpdate --> End

    style Start fill:#e1f5ff
    style Async fill:#fff4e1
    style OrderFound fill:#fff4e1
    style Format fill:#e1ffe1
    style SafeUpdate fill:#ffe1e1
    style End fill:#e1f5ff

Key Business Rules

  • Payment Method Format: [CARD_TYPE]************[LAST_4]
  • Card type converted to uppercase
  • Fixed 12 asterisks for masking
  • Last 4 digits appended
  • Example: VISA************1234
  • Payment Date: Gateway Date converted to Date format
  • Trigger Condition: Only fires when Order__c field is changed
  • Async Processing: Uses Async After Commit for reliable processing
  • Error Handling: SafeUpdateService logs errors without blocking transaction
  • PCI Compliance: Only stores masked card information (last 4 digits)

Dependencies

  • ChargentOrders Package: Transaction and ChargentOrder objects
  • Standard Objects: Order
  • Apex Service: SafeUpdateService (error-safe update handling)
  • Custom Fields:
  • Order.Formatted_PaymentMethod__c
  • Order.Payment_Date__c
  • Transaction.Order__c

Changes

No specific PR references found in the flow description or comments.

Pre-Go-Live Concerns

CRITICAL - Fix Before Go-Live

  • None identified

HIGH - Address Soon After Go-Live

  • SafeUpdateService Errors: Errors are logged but not actively monitored; need alerting
  • Order Relationship: Assumes Order__c always points to valid Order; no validation

MEDIUM - Future Enhancement

  • Format Standardization: Payment method format is formula-based; consider metadata-driven approach
  • Card Type Handling: No validation that card type is valid before formatting
  • Null Handling: Limited null checks on card last 4 digits field
  • Historical Updates: No handling for updating multiple transactions on same order

LOW - Monitor

  • Async Timing: Async after commit may cause slight delay in UI display
  • Collection Handling: Updates single order; could be optimized for bulk scenarios

Maintenance Notes

Complexity: Low - Simple formatting and update logic with safe error handling

Review Schedule: Annual review sufficient unless payment method display requirements change

Testing Requirements: - Test with all major card types (Visa, Mastercard, Amex, Discover) - Test with missing or null card data - Verify formatted payment method displays correctly - Verify payment date is set correctly - Test SafeUpdateService error handling - Test with transactions that don't have associated orders - Verify PCI compliance (only masked data stored)