Payment History

GET /api/v1/payments/history

Retrieves user's payment history with pagination and filtering.

Headers:

Authorization: Bearer <token> or token must be passed in the cookie

Query Parameters:

  • status (optional): Filter by payment status (created, paid, failed, refunded)

  • page (optional): Page number (default: 1)

  • limit (optional): Items per page (default: 10, max: 100)

Example:

GET /api/v1/payments/history?status=paid&page=1&limit=5

Response:

{
  "status": "success",
  "data": {
    "payments": [
      {
        "_id": "65f8a2b4c1d2e3f4a5b6c7d8",
        "orderId": "ORDER_1640995200000_abc123",
        "razorpayOrderId": "order_MzxJ9n7xQw5Pz8",
        "amount": 150000,
        "currency": "INR",
        "status": "paid",
        "orderType": "cart",
        "createdAt": "2024-01-01T10:00:00.000Z",
        "paidAt": "2024-01-01T10:30:00.000Z",
        "cartItems": [
          {
            "product": {
              "_id": "65f8a2b4c1d2e3f4a5b6c7d9",
              "product_name": "Wireless Headphones",
              "main_image": "/images/headphones.jpg",
              "final_price": 500
            },
            "quantity": 2,
            "price": 500
          }
        ]
      }
    ],
    "pagination": {
      "currentPage": 1,
      "totalPages": 3,
      "totalCount": 25,
      "hasNextPage": true,
      "hasPrevPage": false
    }
  }
}
Updated on