Small Laravel 11 project implementing the interview task: pay an order and add points to the user.
- Clone repo
- Copy
.env.exampleto.envand set DB credentials - Install composer dependencies:
composer install
php artisan key:generate
php artisan migrate --seed
php artisan serve
4. Test the endpoint with Postman or curl:
POST http://127.0.0.1:8000/api/orders/{2}}/pay
Body:
{
"user_id": 1
}
Response will be like
{
"message": "Order paid successfully.",
"order": {
"id": 2,
"user_id": 1,
"total_price": "40.50",
"status": "paid",
"created_at": "2025-11-10T00:00:00.000000Z",
"updated_at": "2025-11-10T00:00:00.000000Z"
},
"user_points": 50.50
}