Add subcription feature 9

This commit is contained in:
Urtzi Alfaro
2026-01-16 20:25:45 +01:00
parent fa7b62bd6c
commit 3a7d57ef90
19 changed files with 1833 additions and 985 deletions

View File

@@ -114,10 +114,12 @@ async def register_bakery(
error=str(linking_error))
elif bakery_data.coupon_code:
coupon_validation = payment_service.validate_coupon_code(
from app.services.coupon_service import CouponService
coupon_service = CouponService(db)
coupon_validation = await coupon_service.validate_coupon_code(
bakery_data.coupon_code,
tenant_id,
db
tenant_id
)
if not coupon_validation["valid"]:
@@ -131,10 +133,10 @@ async def register_bakery(
detail=coupon_validation["error_message"]
)
success, discount, error = payment_service.redeem_coupon(
success, discount, error = await coupon_service.redeem_coupon(
bakery_data.coupon_code,
tenant_id,
db
base_trial_days=0
)
if success:
@@ -194,13 +196,15 @@ async def register_bakery(
if coupon_validation and coupon_validation["valid"]:
from app.core.config import settings
from app.services.coupon_service import CouponService
database_manager = create_database_manager(settings.DATABASE_URL, "tenant-service")
async with database_manager.get_session() as session:
success, discount, error = payment_service.redeem_coupon(
coupon_service = CouponService(session)
success, discount, error = await coupon_service.redeem_coupon(
bakery_data.coupon_code,
result.id,
session
base_trial_days=0
)
if success: