Browse Available Content
List all published content
Retrieve paginated content with optional filters:Query Parameters:
page(optional): Page number (default: 1)limit(optional): Items per page (default: 10)category(optional): Filter by category IDtype(optional): Filter by type (video,audio,pdf)minPrice(optional): Minimum price filtermaxPrice(optional): Maximum price filtersearch(optional): Full-text search
File URLs are excluded from public listings for security. They’re only available after purchase.
Purchase Workflow
Create a payment intent
Initiate a purchase by creating a Stripe payment intent:Response:What happens:
- The API validates the content exists and is published
- Checks if you’ve already purchased this content
- Creates a Stripe PaymentIntent for the content price
- Creates a pending purchase record in MongoDB
- Returns a
clientSecretfor completing payment
Complete payment with Stripe
Use the
clientSecret with Stripe.js or Stripe Elements to collect payment:Frontend example (React with Stripe.js):Stripe handles all payment processing. When payment succeeds, Stripe sends a webhook to your API to complete the purchase.
Access Purchased Content
Error Handling
Common error scenarios:| Status Code | Error | Description |
|---|---|---|
| 400 | Already purchased | User already owns this content |
| 401 | Unauthorized | Missing or invalid authentication token |
| 403 | Forbidden | Attempting to access unpurchased content |
| 404 | Not found | Content doesn’t exist or isn’t published |
| 500 | Server error | Internal error during payment processing |
Payment Flow Diagram
Implementation Tips
Webhook Processing: The purchase status is updated asynchronously via webhooks. After payment confirmation:
- Poll the
/payments/status/:paymentIntentIdendpoint - Wait for status to change from
pendingtocompleted - Then redirect to the content access page
Source Code References
- List content:
src/controllers/contentController.js:152 - Create payment intent:
src/controllers/paymentController.js:6 - Access purchased content:
src/controllers/contentController.js:221 - Webhook handler:
src/controllers/paymentController.js:64
Next Steps
Webhooks Setup
Configure Stripe webhooks for payment processing
Payment API Reference
Detailed payment API documentation