Files
firecrawl/apps/api/src/services/billing/issue_credits.ts
T

22 lines
572 B
TypeScript
Raw Normal View History

2024-11-07 20:57:33 +01:00
import { logger } from "../../lib/logger";
2024-10-22 19:47:23 -03:00
import { supabase_service } from "../supabase";
export async function issueCredits(team_id: string, credits: number) {
// Add an entry to supabase coupons
2024-11-07 20:57:33 +01:00
const { error } = await supabase_service.from("coupons").insert({
2024-10-22 19:47:23 -03:00
team_id: team_id,
credits: credits,
status: "active",
// indicates that this coupon was issued from auto recharge
from_auto_recharge: true,
2024-12-15 15:53:24 -03:00
initial_credits: credits,
2024-10-22 19:47:23 -03:00
});
if (error) {
2024-11-07 20:57:33 +01:00
logger.error(`Error adding coupon: ${error}`);
2024-10-22 19:47:23 -03:00
return false;
}
return true;
}