Update app/main.py
Browse files- app/main.py +8 -3
app/main.py
CHANGED
|
@@ -245,6 +245,8 @@ def get_admin_overview(db: Session = Depends(get_db)):
|
|
| 245 |
mrr += float(m.price)
|
| 246 |
elif m.billing_period == "quarterly":
|
| 247 |
mrr += float(m.price) / 3.0
|
|
|
|
|
|
|
| 248 |
elif m.billing_period == "annual":
|
| 249 |
mrr += float(m.price) / 12.0
|
| 250 |
|
|
@@ -1139,6 +1141,8 @@ async def stripe_webhook(request: Request, db: Session = Depends(get_db)):
|
|
| 1139 |
renewal = start + timedelta(days=30)
|
| 1140 |
elif billing_period == "quarterly":
|
| 1141 |
renewal = start + timedelta(days=90)
|
|
|
|
|
|
|
| 1142 |
elif billing_period == "annual":
|
| 1143 |
renewal = start + timedelta(days=365)
|
| 1144 |
else:
|
|
@@ -1512,13 +1516,14 @@ def create_checkout_session(token: str, db: Session = Depends(get_db)):
|
|
| 1512 |
},
|
| 1513 |
"unit_amount": price_cents,
|
| 1514 |
"recurring": {
|
| 1515 |
-
"interval": "month" if plan.billing_period
|
| 1516 |
-
|
|
|
|
| 1517 |
},
|
| 1518 |
"quantity": 1,
|
| 1519 |
}
|
| 1520 |
],
|
| 1521 |
-
mode="subscription" if plan.billing_period in ["monthly", "annual"] else "payment",
|
| 1522 |
success_url=f"{base_url}/student?payment=success",
|
| 1523 |
cancel_url=f"{base_url}/student?payment=cancelled",
|
| 1524 |
customer_email=invite.email,
|
|
|
|
| 245 |
mrr += float(m.price)
|
| 246 |
elif m.billing_period == "quarterly":
|
| 247 |
mrr += float(m.price) / 3.0
|
| 248 |
+
elif m.billing_period == "half_yearly":
|
| 249 |
+
mrr += float(m.price) / 6.0
|
| 250 |
elif m.billing_period == "annual":
|
| 251 |
mrr += float(m.price) / 12.0
|
| 252 |
|
|
|
|
| 1141 |
renewal = start + timedelta(days=30)
|
| 1142 |
elif billing_period == "quarterly":
|
| 1143 |
renewal = start + timedelta(days=90)
|
| 1144 |
+
elif billing_period == "half_yearly":
|
| 1145 |
+
renewal = start + timedelta(days=182) # 6 months (approximately)
|
| 1146 |
elif billing_period == "annual":
|
| 1147 |
renewal = start + timedelta(days=365)
|
| 1148 |
else:
|
|
|
|
| 1516 |
},
|
| 1517 |
"unit_amount": price_cents,
|
| 1518 |
"recurring": {
|
| 1519 |
+
"interval": "month" if plan.billing_period in ["monthly", "half_yearly"] else "year",
|
| 1520 |
+
"interval_count": 6 if plan.billing_period == "half_yearly" else 1,
|
| 1521 |
+
} if plan.billing_period in ["monthly", "half_yearly", "annual"] else None,
|
| 1522 |
},
|
| 1523 |
"quantity": 1,
|
| 1524 |
}
|
| 1525 |
],
|
| 1526 |
+
mode="subscription" if plan.billing_period in ["monthly", "half_yearly", "annual"] else "payment",
|
| 1527 |
success_url=f"{base_url}/student?payment=success",
|
| 1528 |
cancel_url=f"{base_url}/student?payment=cancelled",
|
| 1529 |
customer_email=invite.email,
|