๐ Loyalty Program โ
KitchenAsty includes a points-based loyalty program where customers earn points on purchases and redeem them for discounts.

๐ How Points Work โ
| Action | Points |
|---|---|
| ๐ Place an order | Earn points based on order total |
| ๐ Redeem points | Deduct points for a discount |
| ๐ง Admin adjustment | Staff can manually add or remove points |
Points are tracked on the Customer model (loyaltyPoints field) and each transaction is recorded in the LoyaltyTransaction table.
๐ Transaction Types โ
| Type | Description |
|---|---|
EARN | โฌ๏ธ Points earned from an order |
REDEEM | โฌ๏ธ Points spent for a discount |
ADJUST | ๐ง Manual adjustment by staff |
Each transaction records the points amount, a description, and optionally links to an order.
๐ค Customer Endpoints โ
๐ฐ Check Balance โ
GET /api/loyalty/balance
Authorization: Bearer <customer-token>Returns the customer's current point balance.
๐ Redeem Points โ
POST /api/loyalty/redeem
Authorization: Bearer <customer-token>
{
"points": 100,
"orderId": "order-id"
}Deducts points from the customer's balance.
๐ ๏ธ Admin Endpoints โ
๐ง Adjust Points โ
POST /api/loyalty/customers/:id/adjust
Authorization: Bearer <staff-token>
{
"points": 50,
"description": "Compensation for delayed order"
}Adds or removes points. Use negative values to deduct.
๐ Permissions โ
| Action | Who Can Do It |
|---|---|
| ๐ฐ Check balance | Authenticated customers |
| ๐ Redeem points | Authenticated customers |
| ๐ง Adjust points | Manager, Super Admin |
๐ก API โ
See Loyalty API for the complete endpoint reference.