Overview
DeployHub maintains a complete history of all your payments and subscriptions. All completed orders are stored and accessible through your account dashboard.Invoice data is retrieved from the CompletedOrder model defined in
/prototype/backend/src/models/slices/completedOrder.model.js:1Accessing Your Invoices
You can view all your invoices through the API endpoint:Implementation:
/prototype/backend/src/controllers/slices/user/invoices.js:3API Response
Invoice Data Structure
Each invoice contains the following information:Unique Razorpay order ID (e.g.,
order_rcptid_0.123456789)Total amount paid in paise (divide by 100 for rupees)Example:
862800 paise = ₹8,628Subscription duration purchasedCommon values: 1, 3, 6, 12, 24
Subscription plan typeValues:
"free" or "pro"Payment status (always
"completed" for invoices)Associated project ID created with this subscription
Invoice creation timestamp
Last update timestamp
Invoice Controller Implementation
The invoice retrieval logic is implemented as:The controller fetches all
CompletedOrder records matching the authenticated user’s ID.CompletedOrder Schema
Invoices are stored using the following Mongoose schema:The
timestamps: true option automatically adds createdAt and updatedAt fields.Invoice Creation Flow
Invoices are created during payment verification:Calculating Invoice Amounts
Invoice amounts are calculated with volume discounts:Example Calculations
- 1 Month
- 12 Months
- 24 Months
Subscription Renewal Invoices
When renewing a subscription, a new invoice is created:Renewal invoices preserve the original subscription duration (
months) and pricing from the previous order.Filtering and Sorting Invoices
You can extend the invoice query with filters:Invoice Status Lifecycle
Payment Processing
User completes payment on RazorpayPendingOrder still exists with status “pending”
Common Invoice Scenarios
First-time Pro Subscription
First-time Pro Subscription
When purchasing Pro for the first time:
- User selects plan duration (e.g., 12 months)
- Payment processed through Razorpay
- Invoice created with full amount (₹8,628 for 12 months)
- Project created and linked to invoice
- Subscription activated immediately
Subscription Renewal
Subscription Renewal
When renewing an existing subscription:
- System retrieves previous order duration
- Calculates renewal amount (same duration, no re-selection)
- Payment processed
- New invoice created
- Subscription extended from previous end date
From
renewInfo.controller.js:7-14 - renewal uses previous subscription durationFree Plan Projects
Free Plan Projects
Free plan projects do NOT generate invoices:No CompletedOrder created, no invoice generated.
Failed Payments
Failed Payments
If payment verification fails:
- PendingOrder remains with status “pending”
- NO CompletedOrder created
- NO invoice generated
- PendingOrder auto-expires after 2 hours
- User must retry payment