Skip to main content

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:1

Accessing Your Invoices

You can view all your invoices through the API endpoint:
Implementation: /prototype/backend/src/controllers/slices/user/invoices.js:3

API 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,628
number
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

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 collection
2

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
PendingOrder records auto-expire after 2 hours (7200 seconds) if payment is not completed. Only CompletedOrder records appear as invoices.

Common Invoice Scenarios

When purchasing Pro for the first time:
  1. User selects plan duration (e.g., 12 months)
  2. Payment processed through Razorpay
  3. Invoice created with full amount (₹8,628 for 12 months)
  4. Project created and linked to invoice
  5. Subscription activated immediately
When renewing an existing subscription:
  1. System retrieves previous order duration
  2. Calculates renewal amount (same duration, no re-selection)
  3. Payment processed
  4. New invoice created
  5. Subscription extended from previous end date
From renewInfo.controller.js:7-14 - renewal uses previous subscription duration
Free plan projects do NOT generate invoices:
No CompletedOrder created, no invoice generated.
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