Payments
List All Payments
Admin endpoint to retrieve all payments with pagination and filtering
GET
Administrator endpoint for viewing all payment transactions across the platform. Supports pagination and filtering by payment status.
Authentication
Requires authentication with administrator privileges. Include JWT token in Authorization header.Query Parameters
Page number for pagination (1-based)
Number of purchases per page (max: 100)
Filter by payment status. Options:
pending- Payment intent created but not completedcompleted- Successfully processed paymentfailed- Payment failedrefunded- Payment refunded by admin
Response
Array of purchase objects with populated user and content details
Total number of pages available
Current page number
Total count of purchases matching the filter
Sorting
Results are automatically sorted bypurchasedAt in descending order (newest first).
Status Filter Examples
| Query | Description |
|---|---|
?status=completed | Only successful payments |
?status=pending | Payments awaiting completion |
?status=failed | Failed payment attempts |
?status=refunded | Refunded transactions |
| No status parameter | All payments regardless of status |
Pagination Example
To iterate through all pages:Use Cases
- Generate financial reports
- Monitor payment success rates
- Identify failed payments requiring follow-up
- Track refunded transactions
- Export payment data for accounting
- Customer support investigation
Performance Considerations
- Default limit of 20 items balances performance and usability
- Consider implementing cursor-based pagination for very large datasets
- Populating user and content adds database queries; consider caching for frequent access
- Add indexes on
statusandpurchasedAtfields for faster filtering and sorting
Related Endpoints
- Get Payment Status - View single payment details
- Refund Payment - Process refunds for completed payments
- Create Payment Intent - How payments are created
Implementation Notes
- Requires
authenticateandrequireAdminmiddleware - User is populated with
nameandemailfields only - Content is populated with
titleandtypefields only - Results are sorted by
purchasedAtdescending (newest first) - Query parameters are coerced to numbers where needed
- Source:
src/controllers/paymentController.js:154-179