A Django-based e-commerce app integrated with Paymob Accept's checkout API for payments. Built as part of the Paymob internship technical task.
| Method | Endpoint | Description | Permissions |
|---|---|---|---|
| POST | /api/v1/token/ |
Obtain JWT access & refresh tokens | AllowAny |
| POST | /api/v1/token/refresh/ |
Refresh access token | AllowAny |
| Method | Endpoint | Description | Permissions |
|---|---|---|---|
| POST | /api/v1/register/ |
Register a new user | AllowAny |
| GET | /api/v1/profile/ |
Get current user profile | Authenticated |
| PUT | /api/v1/profile/ |
Update current user profile | Authenticated |
| Method | Endpoint | Description | Permissions |
|---|---|---|---|
| GET | /api/v1/products/ |
List all products | AllowAny |
| GET | /api/v1/products/<id>/ |
Retrieve a product | AllowAny |
| POST | /api/v1/products/ |
Create a new product | Admin Only |
| PUT/PATCH | /api/v1/products/<id>/ |
Update a product | Admin Only |
| DELETE | /api/v1/products/<id>/ |
Soft delete a product (set is_deleted = true) |
Admin Only |
| Method | Endpoint | Description | Permissions |
|---|---|---|---|
| GET | /api/v1/orders/ |
List all user orders | Authenticated |
| GET | /api/v1/orders/<id>/ |
Retrieve a order | Authenticated |
| POST | /api/v1/orders/ |
Create a new order | Authenticated |
| Method | Endpoint | Description | Permissions |
|---|---|---|---|
| POST | /webhook/ |
Receives Paymob webhook callbacks for payment status | Verifies HMAC |
POST /api/v1/orders/
A list of cart items, each specifying the product_id and the desired quantity.
Example
{
"cart_items": [
{ "product_id": 6, "quantity": 1 },
{ "product_id": 4, "quantity": 4 }
]
}- Validation
- Products must exist, be active (
is_deleted = False), and have enough stock.
- Products must exist, be active (
- Reservation
- Stock is immediately deducted (hard reservation).
- Order Creation
-
Order is saved with
pendingstatus. -
A Paymob payment intent is generated (10-minute expiry).
-
Response includes a
payment_url:{ "payment_url": "https://accept.paymob.com/unifiedcheckout/?publicKey=<...>&clientSecret=<...>" }
-
- Success (Webhook)
- Payment confirmed → order marked
success.
- Payment confirmed → order marked
- Failure (Webhook)
- Payment failed → order marked
failed, stock restored.
- Payment failed → order marked
- Timeout
- A scheduled task (via
django-q) runs every 10 minutes. - Pending orders older than 10 minutes → marked
timeout, stock restored.
- A scheduled task (via