Skip to main content

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)

  1. functions/callback/src/cardPaymentRecordTable.py

    • Status: FlexibleStatusAttribute(null=True)
    • Normalizes STRING/BOOL → boolean
  2. functions/callback/src/cardPaymentRecordTableMaster.py

    • Status: FlexibleStatusAttribute(null=True)
    • Normalizes STRING/BOOL → boolean

❌ Using BooleanAttribute (Needs Update)

  1. functions/cardtoken/src/cardPaymentRecordTable.py

    • Status: BooleanAttribute(null=True)
    • Usage: Sets as boolean (False) or boolean result (status.lower() == "success")
    • Action: Update to FlexibleStatusAttribute
  2. functions/cardpaymentdoublechecker/src/cardPaymentRecordTable.py

    • Status: BooleanAttribute(null=True)
    • Usage: Reads as boolean (card_record.status is True)
    • Action: Update to FlexibleStatusAttribute

⚠️ Missing Status Field (But Code Uses It)

  1. functions/qrpayment/src/cardPaymentRecordTable.py

    • Status: NOT DEFINED ⚠️
    • Usage: Sets as STRING ("ERROR" or charge_response.status)
    • Action: Add FlexibleStatusAttribute field
  2. functions/checkstatus/src/tables/cardPaymentRecordTable.py

    • Status: NOT DEFINED ⚠️
    • Usage: Not used in this file
    • Action: No action needed
  3. functions/processPaidOrder/src/tables/cardPaymentRecordTable.py

    • Status: NOT DEFINED ⚠️
    • Usage: Not used in this file
    • Action: No action needed
  4. 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)

  1. 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 ✅
  2. 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) ✅
  3. 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) ✅

❌ String Usage (Needs Fix)

  1. functions/qrpayment/app.py
    • Line 163: self.cardPaymentRecord.status = self.charge_response.status
      • charge_response.status is 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

High Priority (Code Currently Uses Status)

  1. Update functions/cardtoken/src/cardPaymentRecordTable.py

    from functions.callback.src.flexible_status_attribute import FlexibleStatusAttribute
    # Change:
    status = BooleanAttribute(null=True)
    # To:
    status = FlexibleStatusAttribute(null=True)
  2. Update functions/cardpaymentdoublechecker/src/cardPaymentRecordTable.py

    from functions.callback.src.flexible_status_attribute import FlexibleStatusAttribute
    # Change:
    status = BooleanAttribute(null=True)
    # To:
    status = FlexibleStatusAttribute(null=True)
  3. 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
  4. Add status field to functions/qrpayment/src/cardPaymentRecordTable.py

    from functions.callback.src.flexible_status_attribute import FlexibleStatusAttribute
    # Add:
    status = FlexibleStatusAttribute(null=True)

Medium Priority (For Consistency)

  1. 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

Notes

  • The FlexibleStatusAttribute normalizes:

    • STRING "success"True
    • STRING (other) → False
    • BOOL trueTrue
    • BOOL falseFalse
    • NULL → None
  • All code that reads status as boolean will work correctly once tables use FlexibleStatusAttribute

  • Code that sets status as string needs to be updated to set boolean values