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
e5ca4364ba
commit
1805d901a9
|
@ -199,8 +199,13 @@ export async function supaCheckTeamCredits(team_id: string, credits: number) {
|
|||
);
|
||||
}
|
||||
|
||||
if(subscriptionError) {
|
||||
Logger.error(`Subscription error: ${subscriptionError}`);
|
||||
throw new Error(`Subscription error: ${subscriptionError}`);
|
||||
}
|
||||
|
||||
// Free credits, no coupons
|
||||
if (subscriptionError || !subscription) {
|
||||
if (!subscription) {
|
||||
// If there is no active subscription but there are available coupons
|
||||
if (couponCredits >= credits) {
|
||||
return { success: true, message: "Sufficient credits available", remainingCredits: couponCredits };
|
||||
|
@ -214,6 +219,7 @@ export async function supaCheckTeamCredits(team_id: string, credits: number) {
|
|||
.eq("team_id", team_id);
|
||||
|
||||
if (creditUsageError) {
|
||||
Logger.error(`Credit usage error: ${creditUsageError}`);
|
||||
throw new Error(
|
||||
`Failed to retrieve credit usage for team_id: ${team_id}`
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue
Block a user