fix(credit_billing): return chunk.remaining_credits

This commit is contained in:
Gergő Móricz 2024-09-25 20:37:35 +02:00
parent 2073063fb7
commit c1f68c3e0a

View File

@ -191,7 +191,7 @@ export async function supaCheckTeamCredits(chunk: AuthCreditUsageChunk, team_id:
chunk.sub_current_period_start,
chunk.sub_current_period_end
);
return { success: false, message: "Insufficient credits, please upgrade!", remainingCredits: chunk.price_credits - chunk.adjusted_credits_used, chunk };
return { success: false, message: "Insufficient credits, please upgrade!", remainingCredits: chunk.remaining_credits, chunk };
} else if (creditUsagePercentage >= 0.8 && creditUsagePercentage < 1) {
// Send email notification for approaching credit limit
sendNotification(
@ -202,7 +202,7 @@ export async function supaCheckTeamCredits(chunk: AuthCreditUsageChunk, team_id:
);
}
return { success: true, message: "Sufficient credits available", remainingCredits: chunk.price_credits - chunk.adjusted_credits_used, chunk };
return { success: true, message: "Sufficient credits available", remainingCredits: chunk.remaining_credits, chunk };
}
// Count the total credits used by a team within the current billing period and return the remaining credits.