mirror of
https://github.com/mendableai/firecrawl.git
synced 2024-11-16 11:42:24 +08:00
Update credit_billing.ts
This commit is contained in:
parent
ffbf16048f
commit
e5a5ca2446
|
@ -58,10 +58,12 @@ export async function supaCheckTeamCredits(chunk: AuthCreditUsageChunk, team_id:
|
|||
// In case chunk.price_credits is undefined, set it to a large number to avoid mistakes
|
||||
const totalPriceCredits = chunk.price_credits ?? 100000000;
|
||||
// Removal of + credits
|
||||
const creditUsagePercentage = creditsWillBeUsed / totalPriceCredits;
|
||||
const creditUsagePercentage = chunk.adjusted_credits_used / totalPriceCredits;
|
||||
|
||||
// Compare the adjusted total credits used with the credits allowed by the plan
|
||||
if (creditsWillBeUsed > totalPriceCredits) {
|
||||
// Only notify if their actual credits (not what they will use) used is greater than the total price credits
|
||||
if(chunk.adjusted_credits_used > totalPriceCredits) {
|
||||
sendNotification(
|
||||
team_id,
|
||||
NotificationType.LIMIT_REACHED,
|
||||
|
@ -69,6 +71,7 @@ export async function supaCheckTeamCredits(chunk: AuthCreditUsageChunk, team_id:
|
|||
chunk.sub_current_period_end,
|
||||
chunk
|
||||
);
|
||||
}
|
||||
return { success: false, message: "Insufficient credits. For more credits, you can upgrade your plan at https://firecrawl.dev/pricing.", remainingCredits: chunk.remaining_credits, chunk };
|
||||
} else if (creditUsagePercentage >= 0.8 && creditUsagePercentage < 1) {
|
||||
// Send email notification for approaching credit limit
|
||||
|
|
Loading…
Reference in New Issue
Block a user