File size: 861 Bytes
ef4c8c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""

Payment.py: Plan enforcement and payment logic (Stripe stub).

"""
import os
from .Config import PLAN_LIMITS, PLAN_PRICING

class PaymentManager:
    def __init__(self):
        self.stripe_api_key = os.getenv("STRIPE_API_KEY")

    def check_plan_limit(self, plan, requested_tokens):
        limit = PLAN_LIMITS.get(plan, 0)
        return requested_tokens <= limit

    def get_price(self, plan):
        return PLAN_PRICING.get(plan, 0)

    def requires_payment(self, plan, requested_tokens):
        if plan == "free":
            return requested_tokens > PLAN_LIMITS["free"]
        return plan not in PLAN_LIMITS

    def create_checkout_session(self, plan, job_id):
        # Stub: Integrate with Stripe API in production
        return f"https://checkout.stripe.com/pay/{plan}/{job_id}"

payment_manager = PaymentManager()