Square Integration - Remaining Tasks
Vercel Project (ftn-vercel-site)
-
Implement API Functions: Create/adapt API functions (
api/getSquareItems.ts,api/square/oauth/*) using plaintext token logic. -
Install Dependencies:
pnpm install square @sanity/client nanoid. -
Configure Environment Variables: Set required variables (Square App ID/Secret, Sanity Project/Dataset/Token, etc.) in Vercel project settings. Ensure
SANITY_STUDIO_SQUARE_REDIRECT_URIis correct. -
Deploy: Deploy the Vercel project.
Sanity Studio Project (food-truck-nerdz-sanity)
-
Update Vercel Base URL: Replace
VERCEL_API_BASE_URLplaceholder incomponents/SquareMenuItemsViewer.tsxandcomponents/OwnerDashboard.tsxwith the actual deployed Vercel URL.
Vercel Project (ftn-vercel-site) - Post-Setup Enhancements
-
Implement CSRF Protection: Add secure CSRF token validation to
/api/auth/callback/square. -
Implement Owner-Specific Tokens: Modify API functions (
getSquareItems, etc.) to acceptownerId, 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
-
Update Frontend for Owner Tokens: Modify components (
SquareMenuItemsViewer, etc.) to passownerIdwhen calling Vercel API functions. -
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. -
Revisit
socialPostConfig: Update schema/logic based on Square data. -
(Recommended) Implement Token Encryption: Add encryption/decryption to Vercel functions and re-introduce
SANITY_STUDIO_TOKEN_ENCRYPTION_KEY. UpdateownerSquareCredentialsschema.