CardPaymentRecordTable Status Field Analysis
Summary
This document analyzes all instances of CardPaymentRecordTable and how the status field is defined and used across the codebase.
Table Definitions
✅ Already Using FlexibleStatusAttribute (Correct)
-
functions/callback/src/cardPaymentRecordTable.py- Status:
FlexibleStatusAttribute(null=True)✅ - Normalizes STRING/BOOL → boolean
- Status:
-
functions/callback/src/cardPaymentRecordTableMaster.py- Status:
FlexibleStatusAttribute(null=True)✅ - Normalizes STRING/BOOL → boolean
- Status:
❌ Using BooleanAttribute (Needs Update)
-
functions/cardtoken/src/cardPaymentRecordTable.py- Status:
BooleanAttribute(null=True)❌ - Usage: Sets as boolean (
False) or boolean result (status.lower() == "success") - Action: Update to
FlexibleStatusAttribute
- Status:
-
functions/cardpaymentdoublechecker/src/cardPaymentRecordTable.py- Status:
BooleanAttribute(null=True)❌ - Usage: Reads as boolean (
card_record.status is True) - Action: Update to
FlexibleStatusAttribute
- Status:
⚠️ Missing Status Field (But Code Uses It)
-
functions/qrpayment/src/cardPaymentRecordTable.py- Status: NOT DEFINED ⚠️
- Usage: Sets as STRING (
"ERROR"orcharge_response.status) - Action: Add
FlexibleStatusAttributefield
-
functions/checkstatus/src/tables/cardPaymentRecordTable.py- Status: NOT DEFINED ⚠️
- Usage: Not used in this file
- Action: No action needed
-
functions/processPaidOrder/src/tables/cardPaymentRecordTable.py- Status: NOT DEFINED ⚠️
- Usage: Not used in this file
- Action: No action needed
-
dashboard/litdash/tables/card_payment_record_table.py- Status: NOT DEFINED ⚠️
- Usage: Not used in this file
- Action: No action needed
Status Usage Patterns
✅ Boolean Usage (Correct - will work with FlexibleStatusAttribute)
-
functions/cardtoken/app.py- Line 199:
self.cardPaymentRecord.status = self.charge_response.status.lower() == "success"✅ - Line 203:
self.cardPaymentRecord.status = False✅ - Line 231:
self.cardPaymentRecord.status = False✅ - Line 389:
self.cardPaymentRecord.status = False✅ - Status: Already using boolean values ✅
- Line 199:
-
functions/cardpaymentdoublechecker/src/status_checker.py- Line 45:
is_paid = card_record.status is True or card_record.success is True✅ - Status: Reads as boolean (will work with FlexibleStatusAttribute) ✅
- Line 45:
-
functions/callback/callback.py- Line 42:
card_payment_record.__class__.status.set(processor.status)✅ - Line 47:
if processor.status:✅ - Status: Uses processor.status (should be boolean) ✅
- Line 42:
❌ String Usage (Needs Fix)
functions/qrpayment/app.py- Line 163:
self.cardPaymentRecord.status = self.charge_response.status❌charge_response.statusis a STRING (e.g., "success", "failed")
- Line 167:
self.cardPaymentRecord.status = "ERROR"❌ - Line 180:
self.cardPaymentRecord.status = "ERROR"❌ - Action: Change to boolean:
"success"→True"ERROR"or other →False
- Line 163:
Recommended Actions
High Priority (Code Currently Uses Status)
-
Update
functions/cardtoken/src/cardPaymentRecordTable.pyfrom functions.callback.src.flexible_status_attribute import FlexibleStatusAttribute
# Change:
status = BooleanAttribute(null=True)
# To:
status = FlexibleStatusAttribute(null=True) -
Update
functions/cardpaymentdoublechecker/src/cardPaymentRecordTable.pyfrom functions.callback.src.flexible_status_attribute import FlexibleStatusAttribute
# Change:
status = BooleanAttribute(null=True)
# To:
status = FlexibleStatusAttribute(null=True) -
Fix
functions/qrpayment/app.py- Change string assignments to boolean:# Line 163: Change from:
self.cardPaymentRecord.status = self.charge_response.status
# To:
self.cardPaymentRecord.status = self.charge_response.status.lower() == "success"
# Lines 167, 180: Change from:
self.cardPaymentRecord.status = "ERROR"
# To:
self.cardPaymentRecord.status = False -
Add status field to
functions/qrpayment/src/cardPaymentRecordTable.pyfrom functions.callback.src.flexible_status_attribute import FlexibleStatusAttribute
# Add:
status = FlexibleStatusAttribute(null=True)
Medium Priority (For Consistency)
- Create shared FlexibleStatusAttribute module (if not already shared)
- Currently in
functions/callback/src/flexible_status_attribute.py - Consider moving to a shared location if other functions need it
- Currently in
Notes
-
The
FlexibleStatusAttributenormalizes:- STRING
"success"→True - STRING (other) →
False - BOOL
true→True - BOOL
false→False - NULL →
None
- STRING
-
All code that reads
statusas boolean will work correctly once tables useFlexibleStatusAttribute -
Code that sets
statusas string needs to be updated to set boolean values