Skip to main content

Get All Purchases

Retrieve all purchase transactions with optional filtering by status.

Authentication

Authorization
string
required
Bearer token with admin role required

Query Parameters

status
string
Filter purchases by status. Available values:
  • created - Purchase record created but payment not initiated
  • pending - Payment in progress
  • completed - Payment successful and enrollment confirmed
  • failed - Payment failed
  • refunded - Purchase refunded
  • all - Returns all purchases regardless of status (default)

Response

success
boolean
Indicates if the request was successful
purchases
array
Array of purchases sorted by creation date (newest first)
{
  "success": true,
  "purchases": [
    {
      "_id": "65a1b2c3d4e5f6789abcdef0",
      "userId": "user_2abc123def456",
      "courseId": {
        "_id": "65a1b2c3d4e5f6789abcdef5",
        "courseTitle": "Complete Web Development Bootcamp 2024"
      },
      "amount": 3999,
      "currency": "INR",
      "status": "completed",
      "createdAt": "2024-01-15T10:30:00.000Z",
      "updatedAt": "2024-01-15T10:31:23.000Z"
    },
    {
      "_id": "65a1b2c3d4e5f6789abcdef1",
      "userId": "user_3xyz789ghi012",
      "courseId": {
        "_id": "65a1b2c3d4e5f6789abcdef6",
        "courseTitle": "JavaScript Mastery: From Zero to Hero"
      },
      "amount": 2974,
      "currency": "INR",
      "status": "completed",
      "createdAt": "2024-01-15T09:15:00.000Z",
      "updatedAt": "2024-01-15T09:16:45.000Z"
    },
    {
      "_id": "65a1b2c3d4e5f6789abcdef2",
      "userId": "user_4mno345pqr678",
      "courseId": {
        "_id": "65a1b2c3d4e5f6789abcdef7",
        "courseTitle": "Python for Data Science"
      },
      "amount": 4499,
      "currency": "INR",
      "status": "failed",
      "createdAt": "2024-01-15T08:45:00.000Z",
      "updatedAt": "2024-01-15T08:46:12.000Z"
    },
    {
      "_id": "65a1b2c3d4e5f6789abcdef3",
      "userId": "user_5stu901vwx234",
      "courseId": {
        "_id": "65a1b2c3d4e5f6789abcdef8",
        "courseTitle": "React Advanced Patterns"
      },
      "amount": 5999,
      "currency": "INR",
      "status": "pending",
      "createdAt": "2024-01-15T07:20:00.000Z",
      "updatedAt": "2024-01-15T07:20:00.000Z"
    }
  ]
}

Example Requests

curl -X GET "https://api.skillrise.com/api/admin/purchases" \
  -H "Authorization: Bearer YOUR_ADMIN_TOKEN"

Notes

  • Purchases are sorted by creation date in descending order (newest first)
  • The amount field represents the final price after any discounts applied
  • Revenue calculations should only include purchases with status: 'completed'
  • The courseId field is populated with basic course information (ID and title)
  • If no status query parameter is provided or status=all, all purchases are returned
  • Currency defaults to ‘INR’ (Indian Rupee) for all transactions