Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Update credit_billing.ts

Nicolas7689c31d3584
diff --git a/apps/api/src/services/billing/credit_billing.ts b/apps/api/src/services/billing/credit_billing.ts
index a5060261c..37db664ed 100644
--- a/apps/api/src/services/billing/credit_billing.ts
+++ b/apps/api/src/services/billing/credit_billing.ts
@@ -40,8 +40,10 @@ export async function supaBillTeam(team_id: string, credits: number) {
let sortedCoupons = coupons.sort((a, b) => b.credits - a.credits);
// using coupon credits:
if (couponCredits > 0) {
+ // if there is no subscription and they have enough coupon credits
if (!subscription) {
// using only coupon credits:
+ // if there are enough coupon credits
if (couponCredits >= credits) {
// remove credits from coupon credits
let usedCredits = credits;