Flow Name: I2C Saved Payment Method¶
Last Updated: 2025-10-22 Source Code: I2C_Saved_Payment_Method.flow-meta.xml
API Name: I2C_Saved_Payment_Method Status: Active Type: Custom Trigger: Screen Flow (User-Initiated)
Business Purpose¶
This flow provides members with a secure, self-service interface to save and update credit card information for auto-renewal subscriptions, integrating with the Chargent payment gateway for secure tokenization while never storing actual card numbers.
Process Flow¶
- Gateway Selection: Retrieves active Chargent payment gateway
- Account Resolution: Identifies Account either from input parameter or current user
- Payment Method Screen: Displays custom LWC for credit card entry
- Card Type Validation: Ensures card type is recognized (not 'default' or unknown)
- Tokenization: Submits card data to Chargent for secure token creation
- Log Verification: Checks Chargent logs for success/failure status
- Account Update: Sets new payment method as default auto-renewal method
- User Feedback: Displays success notice or specific error messages
📊 Click to view Process Flow Diagram
flowchart TD
Start([Start: Flow Launched]) --> GetGateway[Get Active Payment Gateway]
GetGateway --> CheckAccount{Account ID Provided?}
CheckAccount -->|Yes| GetAccount1[Get Account by ID]
CheckAccount -->|No| GetAccount2[Get User's Account]
GetAccount1 --> Screen[Payment Method Screen]
GetAccount2 --> Screen
Screen --> UserInput[User Enters Card Details]
UserInput --> CheckCard{Card Type Valid?}
CheckCard -->|No| ErrorCard[Show Card Type Error]
CheckCard -->|Yes| Tokenize[Tokenize with Chargent]
Tokenize --> TokenSuccess{Tokenization Success?}
TokenSuccess -->|No| ErrorToken[Show Error Message]
TokenSuccess -->|Yes| GetLog[Get Chargent Log]
GetLog --> CheckLog{Log Status?}
CheckLog -->|Success| UpdateAccount[Set as Default Payment Method]
CheckLog -->|Fail| ErrorLog[Show Log Error Message]
CheckLog -->|Not Found| ErrorGeneral[Show General Error]
UpdateAccount --> Success[Show Success Notice]
ErrorCard --> Screen
ErrorToken --> Screen
ErrorLog --> Screen
ErrorGeneral --> Screen
Success --> End([End])
style Start fill:#e1f5ff
style CheckAccount fill:#fff4e1
style CheckCard fill:#fff4e1
style TokenSuccess fill:#fff4e1
style CheckLog fill:#fff4e1
style Tokenize fill:#ffe1e1
style UpdateAccount fill:#ffe1e1
style End fill:#e1f5ff
Key Business Rules¶
- Gateway Selection: Uses oldest active gateway that supports tokenization
- Account Resolution: Falls back to current user's Account if no accountId provided
- Card Type Validation: Rejects 'default' or unrecognized card types before submission
- Billing Address: Populates from Account mailing address; uses Region_Territory__c if State is blank
- Cardholder Name Parsing: Splits into first/last name for gateway submission
- Default Email: Uses 'invalid@aanp.org' for tokenization to maintain privacy
- Auto-Renewal: Successfully saved payment method becomes default for Account auto-renewals
- Error Preservation: Maintains user-entered data on errors for easy resubmission
Dependencies¶
- Chargent Base Package: Gateway, Payment Method, Log objects
- Lightning Web Component: c:i2cPaymentMethods
- Account Fields: Auto_Renewal_Payment_Method__c, Address_Mailing_Company__c, Region_Territory__c
- Apex Action: ChargentBase__FlowPMTokenization
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¶
- Email Privacy: Using 'invalid@aanp.org' may cause gateway validation issues
- State/Region Logic: Complex formula for state code may not cover all edge cases
MEDIUM - Future Enhancement¶
- Gateway Selection: Oldest gateway logic is fragile; should use specific gateway identifier
- Error Messages: Some errors use generic fault messages; need more user-friendly wording
- Validation: No client-side validation before submission; all validation at gateway level
- Component State: Complex state management for showing modified values could be simplified
LOW - Monitor¶
- Company Name Default: Uses 'N/A' for missing company; verify gateway accepts this
- Security Mode: Runs in SystemModeWithoutSharing; verify this doesn't expose sensitive data
- CVV Handling: Stored temporarily in variables; ensure proper clearing
Maintenance Notes¶
Complexity: Medium to High - Complex error handling, LWC integration, and payment gateway interaction
Review Schedule: Quarterly review recommended due to payment processing and PCI compliance implications
Testing Requirements: - Test with valid credit cards (all major types: Visa, MC, Amex, Discover) - Test invalid card scenarios (expired, incorrect CVV, etc.) - Test error handling for each failure path - Verify Account update occurs correctly - Test with both provided accountId and current user context - Verify LWC component displays correctly and maintains state - Test cardholder name parsing (single name, multiple names, etc.)