Overview
Each project has its own billing information, including the current plan, subscription period, request usage, and payment history.Get Project Billing
GET /api/projects/:id/billing
Retrieve billing information and payment history for a project.
string
required
Project ID (MongoDB ObjectId)
Project Plan Information
Plan Types
free
Free tier with usage limits
pro
Professional tier with increased limits
Project Billing Fields
The project model includes these billing-related fields:string
default:"free"
Current subscription plan (
"free" or "pro")Date
Subscription period start date
Date
Subscription period end date
ObjectId
Reference to the most recent completed order
number
default:"0"
Total HTTP requests served by this project
Payment History
The billing endpoint returns up to 20 most recent orders:Order Fields
string
Unique order identifier from payment gateway
number
Number of months purchased in this order
number
Payment amount (in smallest currency unit, e.g., cents)
string
Plan associated with this payment (
"free" or "pro")string
Order status (typically
"completed" for successful payments)Date
Timestamp when the order was created
Subscription Period Calculation
When a project is upgraded to pro:- Start Date: Set to the payment timestamp
- End Date: Calculated as
startDate + (months * 30 days) - Payment ID: Reference to the completed order
Subscription dates are only set for paid plans. Free tier projects will have
null for startDate and endDate.Request Tracking
ThetotalRequest field tracks cumulative HTTP requests:
/src/workers/Requestcountworker.js
Example: Display Billing Information
Example: Check Subscription Status
Plan Upgrade Flow
1. Initialize Payment
2. Verify Payment
After successful payment:3. Update Project
The verify endpoint updates:project.plan="pro"project.startDate= current timestampproject.endDate= calculated based on monthsproject.paymentId= reference to completed order
4. Create Order Record
ACompletedOrder document is created:
Usage Limits by Plan
Plan limits are defined in/src/constants/planLimits.js:
When a project reaches its request limit, further requests may be throttled or blocked depending on the plan enforcement strategy.
Price Information
Pricing is defined in/src/constants/planPrice.js:
Error Responses
404 Not Found
- Project ID doesn’t exist
- Project doesn’t belong to authenticated user
- Project status is ‘deleted’
500 Server Error
Billing Dashboard Components
When building a billing dashboard, include:Current Plan
Display plan name, start/end dates, and days remaining
Usage Metrics
Show total requests and percentage of monthly limit used
Payment History
List recent orders with dates, amounts, and status
Renewal Options
Provide upgrade/renewal buttons based on current plan
Automatic Renewal
The system includes renewal endpoints:POST /api/subscription/renew- Initialize renewalPOST /api/subscription/verify- Verify renewal paymentGET /api/subscription/renewInfo- Get renewal information
endDate by the purchased number of months without interrupting service.
Projects on the free tier can be upgraded to pro at any time. Pro tier projects can be renewed before expiration to extend the subscription period.