Skip to main content
GET
/
api
/
payments
/
status
/
:paymentIntentId
curl -X GET https://api.vaniykempire.com/api/payments/status/pi_3MtwBwLkdIwHu7ix28a3tqPa \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
{
  "purchase": {
    "_id": "65f1a2b3c4d5e6f7g8h9i0j1",
    "user": "507f1f77bcf86cd799439011",
    "content": {
      "_id": "507f191e810c19729de860ea",
      "title": "Advanced React Patterns",
      "description": "Learn advanced React patterns and best practices",
      "type": "course",
      "thumbnailUrl": "https://cdn.vaniykempire.com/thumbnails/react-course.jpg"
    },
    "amount": 29.99,
    "stripePaymentIntentId": "pi_3MtwBwLkdIwHu7ix28a3tqPa",
    "status": "completed",
    "purchasedAt": "2024-03-15T10:30:00.000Z"
  }
}
Retrieves the purchase record and status for a specific Stripe payment intent. This endpoint is used to check whether a payment has been completed, is still pending, has failed, or has been refunded.

Authentication

Requires authentication. Users can only view their own payment status.

Path Parameters

paymentIntentId
string
required
The Stripe payment intent ID (starts with pi_). This is returned when creating a payment intent or can be obtained from Stripe webhooks.

Response

purchase
object
The purchase record with populated content details

Purchase Status Values

StatusDescription
pendingPayment intent created, waiting for payment completion
completedPayment successfully processed by Stripe
failedPayment failed (card declined, insufficient funds, etc.)
refundedPayment was refunded by an administrator
curl -X GET https://api.vaniykempire.com/api/payments/status/pi_3MtwBwLkdIwHu7ix28a3tqPa \
  -H "Authorization: Bearer YOUR_JWT_TOKEN"
{
  "purchase": {
    "_id": "65f1a2b3c4d5e6f7g8h9i0j1",
    "user": "507f1f77bcf86cd799439011",
    "content": {
      "_id": "507f191e810c19729de860ea",
      "title": "Advanced React Patterns",
      "description": "Learn advanced React patterns and best practices",
      "type": "course",
      "thumbnailUrl": "https://cdn.vaniykempire.com/thumbnails/react-course.jpg"
    },
    "amount": 29.99,
    "stripePaymentIntentId": "pi_3MtwBwLkdIwHu7ix28a3tqPa",
    "status": "completed",
    "purchasedAt": "2024-03-15T10:30:00.000Z"
  }
}

Error Codes

Status CodeDescription
200Payment status retrieved successfully
401Not authenticated
404Payment intent not found or doesn’t belong to user
500Server error

Security

  • Users can only view payment status for their own purchases
  • The query filters by both paymentIntentId and authenticated userId
  • Payment intents from other users will return 404

Use Cases

  • Poll this endpoint after payment to check if webhook processed successfully
  • Display payment history to users
  • Verify purchase before granting content access
  • Show refund status to users

Implementation Notes

  • Content is populated with title, description, type, and thumbnailUrl fields
  • User field is not populated in the response (only the ObjectId is returned)
  • Source: src/controllers/paymentController.js:133-151

Build docs developers (and LLMs) love