mirror of
https://git.mirrors.martin98.com/https://github.com/mendableai/firecrawl
synced 2025-08-05 16:50:40 +08:00
Update credit_billing.ts
This commit is contained in:
parent
ffbf16048f
commit
e5a5ca2446
@ -58,17 +58,20 @@ export async function supaCheckTeamCredits(chunk: AuthCreditUsageChunk, team_id:
|
|||||||
// In case chunk.price_credits is undefined, set it to a large number to avoid mistakes
|
// In case chunk.price_credits is undefined, set it to a large number to avoid mistakes
|
||||||
const totalPriceCredits = chunk.price_credits ?? 100000000;
|
const totalPriceCredits = chunk.price_credits ?? 100000000;
|
||||||
// Removal of + credits
|
// 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
|
// Compare the adjusted total credits used with the credits allowed by the plan
|
||||||
if (creditsWillBeUsed > totalPriceCredits) {
|
if (creditsWillBeUsed > totalPriceCredits) {
|
||||||
sendNotification(
|
// Only notify if their actual credits (not what they will use) used is greater than the total price credits
|
||||||
team_id,
|
if(chunk.adjusted_credits_used > totalPriceCredits) {
|
||||||
|
sendNotification(
|
||||||
|
team_id,
|
||||||
NotificationType.LIMIT_REACHED,
|
NotificationType.LIMIT_REACHED,
|
||||||
chunk.sub_current_period_start,
|
chunk.sub_current_period_start,
|
||||||
chunk.sub_current_period_end,
|
chunk.sub_current_period_end,
|
||||||
chunk
|
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 };
|
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) {
|
} else if (creditUsagePercentage >= 0.8 && creditUsagePercentage < 1) {
|
||||||
// Send email notification for approaching credit limit
|
// Send email notification for approaching credit limit
|
||||||
|
Loading…
x
Reference in New Issue
Block a user