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:string
required
Unique Razorpay order ID (e.g.,
order_rcptid_0.123456789)number
required
Total amount paid in paise (divide by 100 for rupees)Example:
862800 paise = ₹8,628number
required
Subscription duration purchasedCommon values: 1, 3, 6, 12, 24
string
required
Subscription plan typeValues:
"free" or "pro"string
required
Payment status (always
"completed" for invoices)ObjectId
Associated project ID created with this subscription
Date
Invoice creation timestamp
Date
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:1
Payment Initiated
User completes payment through Razorpay interface
2
Payment Verified
Server verifies Razorpay signature using HMAC-SHA256
3
Order Completed
System creates CompletedOrder record
4
Project Created
New project linked to the payment record
5
Invoice Available
CompletedOrder appears in user’s invoice list immediately
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
1
Pending Order Created
Initial order stored in
PendingOrder collection2
Payment Processing
User completes payment on RazorpayPendingOrder still exists with status “pending”
3
Payment Verified
Server confirms payment signaturePendingOrder updated:
4
Invoice Generated
CompletedOrder created as permanent invoice record
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
Downloading Invoice Data
To export your invoices:Next Steps
Payment Methods
Configure Razorpay integration
Plans & Pricing
View available plans
Usage Limits
Monitor resource quotas
API Reference
Integrate invoices API