浏览代码

fix: update ShopRenter ENV variable names to APP prefix #96

Updated all ShopRenter Edge Functions to use the new environment
variable names with APP prefix for easier identification:
- SHOPRENTER_CLIENT_ID → SHOPRENTER_APP_CLIENT_ID
- SHOPRENTER_CLIENT_SECRET → SHOPRENTER_APP_CLIENT_SECRET

Files updated:
- oauth-shoprenter-init
- oauth-shoprenter-callback
- webhook-shoprenter-uninstall
- api (finalize-shoprenter endpoint)
- _shared/shoprenter-client.ts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
Claude 5 月之前
父节点
当前提交
bdd12611fe

+ 3 - 3
supabase/functions/_shared/shoprenter-client.ts

@@ -313,13 +313,13 @@ export async function getValidAccessToken(storeId: string): Promise<string> {
   // Final fallback: use global credentials from environment (for testing or when store has NULL credentials)
   // Final fallback: use global credentials from environment (for testing or when store has NULL credentials)
   if (!clientId || !clientSecret) {
   if (!clientId || !clientSecret) {
     console.log('[ShopRenter] No client credentials in database, using global credentials from environment')
     console.log('[ShopRenter] No client credentials in database, using global credentials from environment')
-    clientId = Deno.env.get('SHOPRENTER_CLIENT_ID')
-    clientSecret = Deno.env.get('SHOPRENTER_CLIENT_SECRET')
+    clientId = Deno.env.get('SHOPRENTER_APP_CLIENT_ID')
+    clientSecret = Deno.env.get('SHOPRENTER_APP_CLIENT_SECRET')
   }
   }
 
 
   // Validate client credentials are available
   // Validate client credentials are available
   if (!clientId || !clientSecret) {
   if (!clientId || !clientSecret) {
-    throw new Error('ShopRenter client credentials not found in database or environment. Please reconnect the store or configure SHOPRENTER_CLIENT_ID and SHOPRENTER_CLIENT_SECRET.')
+    throw new Error('ShopRenter client credentials not found in database or environment. Please reconnect the store or configure SHOPRENTER_APP_CLIENT_ID and SHOPRENTER_APP_CLIENT_SECRET.')
   }
   }
 
 
   // If we have client credentials, use client_credentials flow to get a fresh token
   // If we have client credentials, use client_credentials flow to get a fresh token

+ 2 - 2
supabase/functions/api/index.ts

@@ -172,8 +172,8 @@ serve(async (req) => {
       }
       }
 
 
       // Get client credentials from environment (app-level credentials)
       // Get client credentials from environment (app-level credentials)
-      const clientId = Deno.env.get('SHOPRENTER_CLIENT_ID')
-      const clientSecret = Deno.env.get('SHOPRENTER_CLIENT_SECRET')
+      const clientId = Deno.env.get('SHOPRENTER_APP_CLIENT_ID')
+      const clientSecret = Deno.env.get('SHOPRENTER_APP_CLIENT_SECRET')
 
 
       // Create store record with phone_number_id
       // Create store record with phone_number_id
       // IMPORTANT: Store client credentials in api_key/api_secret for token renewal
       // IMPORTANT: Store client credentials in api_key/api_secret for token renewal

+ 3 - 3
supabase/functions/oauth-shoprenter-callback/index.ts

@@ -123,14 +123,14 @@ serve(wrapHandler('oauth-shoprenter-callback', async (req) => {
     }
     }
 
 
     // Get environment variables
     // Get environment variables
-    const shoprenterClientId = Deno.env.get('SHOPRENTER_CLIENT_ID')
-    const shoprenterClientSecret = Deno.env.get('SHOPRENTER_CLIENT_SECRET')
+    const shoprenterClientId = Deno.env.get('SHOPRENTER_APP_CLIENT_ID')
+    const shoprenterClientSecret = Deno.env.get('SHOPRENTER_APP_CLIENT_SECRET')
     const frontendUrl = Deno.env.get('FRONTEND_URL') || 'https://shopcall.ai'
     const frontendUrl = Deno.env.get('FRONTEND_URL') || 'https://shopcall.ai'
     const supabaseUrl = Deno.env.get('SUPABASE_URL')!
     const supabaseUrl = Deno.env.get('SUPABASE_URL')!
     const supabaseServiceKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
     const supabaseServiceKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
 
 
     if (!shoprenterClientId || !shoprenterClientSecret) {
     if (!shoprenterClientId || !shoprenterClientSecret) {
-      console.error('SHOPRENTER_CLIENT_ID or SHOPRENTER_CLIENT_SECRET not configured')
+      console.error('SHOPRENTER_APP_CLIENT_ID or SHOPRENTER_APP_CLIENT_SECRET not configured')
       return new Response(
       return new Response(
         JSON.stringify({ error: 'ShopRenter integration not configured' }),
         JSON.stringify({ error: 'ShopRenter integration not configured' }),
         { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
         { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }

+ 2 - 2
supabase/functions/oauth-shoprenter-init/index.ts

@@ -30,11 +30,11 @@ serve(wrapHandler('oauth-shoprenter-init', async (req) => {
     }
     }
 
 
     // Get environment variables
     // Get environment variables
-    const shoprenterClientId = Deno.env.get('SHOPRENTER_CLIENT_ID')
+    const shoprenterClientId = Deno.env.get('SHOPRENTER_APP_CLIENT_ID')
     const frontendUrl = Deno.env.get('FRONTEND_URL') || 'https://shopcall.ai'
     const frontendUrl = Deno.env.get('FRONTEND_URL') || 'https://shopcall.ai'
 
 
     if (!shoprenterClientId) {
     if (!shoprenterClientId) {
-      console.error('SHOPRENTER_CLIENT_ID not configured')
+      console.error('SHOPRENTER_APP_CLIENT_ID not configured')
       return new Response(
       return new Response(
         JSON.stringify({ error: 'ShopRenter integration not configured' }),
         JSON.stringify({ error: 'ShopRenter integration not configured' }),
         { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }
         { status: 500, headers: { ...corsHeaders, 'Content-Type': 'application/json' } }

+ 2 - 2
supabase/functions/webhook-shoprenter-uninstall/index.ts

@@ -82,12 +82,12 @@ serve(wrapHandler('webhook-shoprenter-uninstall', async (req) => {
     }
     }
 
 
     // Get environment variables
     // Get environment variables
-    const shoprenterClientSecret = Deno.env.get('SHOPRENTER_CLIENT_SECRET')
+    const shoprenterClientSecret = Deno.env.get('SHOPRENTER_APP_CLIENT_SECRET')
     const supabaseUrl = Deno.env.get('SUPABASE_URL')!
     const supabaseUrl = Deno.env.get('SUPABASE_URL')!
     const supabaseServiceKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
     const supabaseServiceKey = Deno.env.get('SUPABASE_SERVICE_ROLE_KEY')!
 
 
     if (!shoprenterClientSecret) {
     if (!shoprenterClientSecret) {
-      console.error('SHOPRENTER_CLIENT_SECRET not configured')
+      console.error('SHOPRENTER_APP_CLIENT_SECRET not configured')
       // Still return 200 to prevent retries
       // Still return 200 to prevent retries
       return new Response(
       return new Response(
         JSON.stringify({ message: 'Configuration error' }),
         JSON.stringify({ message: 'Configuration error' }),