Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

fix(billing): use price metadata for auto_recharge checks (#2807)

firecrawl-spring[bot]e7cd06c0e110
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index 65a150ff0..b4902f8f3 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -186,7 +186,7 @@ export async function getACUC(
? supabase_rr_service
: supabase_service;
({ data, error } = await client.rpc(
- "auth_credit_usage_chunk_41",
+ "auth_credit_usage_chunk_42",
{
input_key: api_key,
i_is_extract: isExtract,
@@ -316,7 +316,7 @@ export async function getACUCTeam(
? supabase_rr_service
: supabase_service;
({ data, error } = await client.rpc(
- "auth_credit_usage_chunk_41_from_team",
+ "auth_credit_usage_chunk_42_from_team",
{
input_team: team_id,
i_is_extract: isExtract,
diff --git a/apps/api/src/services/billing/auto_charge.ts b/apps/api/src/services/billing/auto_charge.ts
index a7d838cc2..35633a254 100644
--- a/apps/api/src/services/billing/auto_charge.ts
+++ b/apps/api/src/services/billing/auto_charge.ts
@@ -141,9 +141,9 @@ async function _autoChargeScale(
const { data: rechargesThisMonth, error: rechargesThisMonthError } =
await supabase_service
.from("subscriptions")
- .select("*")
+ .select("*, prices!inner(*)")
.eq("team_id", chunk.team_id)
- .eq("metadata->>auto_recharge", "true")
+ .eq("prices.metadata->>auto_recharge", "true")
.gte("current_period_start", currentMonth.toISOString());
if (rechargesThisMonthError || !rechargesThisMonth) {