Square Integration - Remaining Tasks

Vercel Project (ftn-vercel-site)

  1. Implement API Functions: Create/adapt API functions (api/getSquareItems.ts, api/square/oauth/*) using plaintext token logic.

  2. Install Dependencies: pnpm install square @sanity/client nanoid.

  3. Configure Environment Variables: Set required variables (Square App ID/Secret, Sanity Project/Dataset/Token, etc.) in Vercel project settings. Ensure SANITY_STUDIO_SQUARE_REDIRECT_URI is correct.

  4. Deploy: Deploy the Vercel project.

Sanity Studio Project (food-truck-nerdz-sanity)

  1. Update Vercel Base URL: Replace VERCEL_API_BASE_URL placeholder in components/SquareMenuItemsViewer.tsx and components/OwnerDashboard.tsx with the actual deployed Vercel URL.

Vercel Project (ftn-vercel-site) - Post-Setup Enhancements

  1. Implement CSRF Protection: Add secure CSRF token validation to /api/auth/callback/square.

  2. Implement Owner-Specific Tokens: Modify API functions (getSquareItems, etc.) to accept ownerId, retrieve the owner’s token from Sanity (ownerSquareCredentials), handle refresh logic, and use the specific token for Square API calls.

Sanity Studio Project (food-truck-nerdz-sanity) - Post-Setup Enhancements

  1. Update Frontend for Owner Tokens: Modify components (SquareMenuItemsViewer, etc.) to pass ownerId when calling Vercel API functions.

  2. Develop Custom Input Components: Create Sanity input components for fields storing Square IDs (squareLocationId, squareCategoryIds) that use the owner’s token to fetch/display Square data.

  3. Revisit socialPostConfig: Update schema/logic based on Square data.

  4. (Recommended) Implement Token Encryption: Add encryption/decryption to Vercel functions and re-introduce SANITY_STUDIO_TOKEN_ENCRYPTION_KEY. Update ownerSquareCredentials schema.