Files
sasa-membership/SQUARE_CHECKLIST.md
nathanb 632e66e21d Add member profile questions, admin tooling, legal pages, and fast tests
- Add configurable profile questions with conditional visibility, admin-only fields, user answers, and seeded onboarding/volunteer questions
  - Add admin UI for managing profile questions and member profile answers
  - Add volunteer level/profile data support across backend schemas, models, API, and migration
  - Update dashboard/profile UI, super admin menu, membership service types, and related styling
  - Add privacy policy, terms of service, cookie notice, and footer links
  - Add frontend Vitest coverage for profile question logic
  - Add backend pytest coverage for profile answer normalization and validation
  - Update restart.sh to build, run frontend/backend unit tests, and restart only after tests pass
  - Refresh README, quickstart, project structure, instructions, and Square docs to match current app features
    - Protect feature flag reload behind super-admin access
    - Restrict admin-triggered password resets so admins can only reset member accounts
    - Replace email template HTML preview rendering with escaped text preview
    - Update docs for feature flag reload access, password reset scope, and email template preview safety

    -- test user questions are also made by AI and not very useful. but i didn't know what to put there so its good enough for a test
2026-05-04 22:05:58 +01:00

5.9 KiB

Square Payment Integration - Implementation Checklist

Completed Tasks

Backend Implementation

  • Added Square SDK to requirements.txt (squareup==43.2.0.20251016)
  • Created square_service.py with payment processing logic
  • Added Square configuration to config.py (SQUARE_APPLICATION_ID)
  • Created Square payment schemas in schemas.py
    • SquarePaymentRequest
    • SquarePaymentResponse
    • SquareRefundRequest
  • Added Square payment endpoints to payments.py
    • GET /api/v1/payments/config/square
    • POST /api/v1/payments/square/process
    • POST /api/v1/payments/square/refund

Frontend Implementation

  • Created SquarePayment.tsx component
    • Square Web Payments SDK integration
    • Card input form
    • Payment tokenization
    • Error handling
  • Updated MembershipSetup.tsx component
    • Payment method selection UI
    • Integration with SquarePayment
    • Cash payment option
    • Improved flow logic
  • Added Square SDK script to index.html

Configuration

  • Updated .env.example with Square variables and comments
  • Verified all Square config variables in config.py

Documentation

  • Created SQUARE_PAYMENT_SETUP.md - Comprehensive setup guide
  • Created SQUARE_IMPLEMENTATION.md - Implementation details
  • Created SQUARE_QUICKSTART.md - Quick start guide
  • Updated restart.sh - Build, fast tests, and restart helper

Code Quality

  • No Python syntax errors
  • Proper error handling implemented
  • Security best practices followed
  • PCI compliance maintained (tokenization)

📋 Deployment Checklist

Before deploying, complete these steps:

1. Square Account Setup

  • Create/login to Square Developer account
  • Create application in Square Dashboard
  • Copy Sandbox credentials:
    • Access Token
    • Application ID
    • Location ID

2. Environment Configuration

  • Create/update .env file
  • Add SQUARE_ACCESS_TOKEN
  • Add SQUARE_APPLICATION_ID
  • Add SQUARE_LOCATION_ID
  • Set SQUARE_ENVIRONMENT=sandbox

3. Deployment

  • Run ./restart.sh OR
  • Run docker compose build
  • Run docker compose run --rm frontend npm test
  • Run docker compose run --rm backend pytest -q
  • Run docker compose up -d
  • Verify containers are running: docker compose ps

4. Testing

  • Access frontend at http://localhost:8050 or HTTPS at https://localhost:8443
  • Login/register a user
  • Navigate to membership setup
  • Select a membership tier
  • Choose "Credit/Debit Card" payment
  • Test with card: 4111 1111 1111 1111
  • Verify payment succeeds
  • Check membership is activated
  • Verify email is sent
  • Test cash payment option
  • Verify admin can see payments

5. Admin Testing

  • Login as admin
  • View all payments
  • Test payment refund (if needed)
  • Approve cash payment

6. Production Preparation (When Ready)

  • Get Square production credentials
  • Complete Square account verification
  • Test in sandbox thoroughly first
  • Update .env with production credentials
  • Change SQUARE_ENVIRONMENT=production
  • Update Square SDK URL in index.html to production
  • Test with real card (small amount, can refund)
  • Monitor logs and Square Dashboard

🎯 Quick Test Script

After deployment, run these commands to verify:

# Check backend is running
curl http://localhost:8050/api/v1/payments/config/square

# Expected output (with your actual IDs):
# {
#   "application_id": "sandbox-sq0idb-...",
#   "location_id": "LXXX...",
#   "environment": "sandbox"
# }

# Check frontend is running
curl http://localhost:8050

# Check logs
docker compose logs backend | grep -i square

📊 Testing Matrix

Test Case Expected Result Status
Square payment - valid card Payment success, membership activated [ ]
Square payment - declined card Error shown, payment not created [ ]
Cash payment Payment pending, membership pending [ ]
Admin approve cash payment Membership activated [ ]
Admin refund Square payment Payment refunded in Square [ ]
Email sent on activation User receives email [ ]

🔍 Verification Commands

# Check Square SDK installed
docker compose exec backend pip list | grep square

# Check configuration loaded
docker compose exec backend python -c "from app.core.config import settings; print(settings.SQUARE_ENVIRONMENT)"

# Check database has payments
docker exec -it membership_mysql mysql -u "${DATABASE_USER}" -p -e "SELECT * FROM ${DATABASE_NAME}.payments LIMIT 5;"

# Check frontend files
ls -la frontend/src/components/SquarePayment.tsx

🐛 Common Issues & Solutions

Issue Solution
"Module not found: squareup" Rebuild backend: docker compose build backend
"SQUARE_APPLICATION_ID not found" Add to .env and restart containers
Square SDK not loading Check browser console, verify script tag in index.html
Payment fails with 401 Check SQUARE_ACCESS_TOKEN is correct
Payment fails with location error Verify SQUARE_LOCATION_ID matches your account

📝 Notes

  • All Square credentials are for SANDBOX by default
  • No real money is charged in sandbox mode
  • Test cards work only in sandbox environment
  • Keep .env file secure and never commit to git
  • Monitor Square Dashboard for transaction details
  • Check backend logs for detailed error messages

Sign-off

  • All backend code implemented and tested
  • All frontend code implemented and tested
  • Documentation completed
  • Deployment script created and tested
  • Environment variables documented
  • Ready for Square account setup
  • Ready for deployment

Implementation Status: COMPLETE - Ready for Square credentials and deployment Next Step: Follow SQUARE_QUICKSTART.md to get Square credentials and deploy