# Quick Reference: Coupon System

## Available Coupon Codes

| Code | Discount | Service | Original Price | Final Price |
|------|----------|---------|----------------|-------------|
| `NOCOST` | 100% OFF | Website Submission / AI Website | $12.99 | **FREE** |
| `FWF01` | 70% OFF | Website Submission / AI Website | $12.99 | **$3.90** |
| `NOCOST_JOB` | 100% OFF | Job Post | $15.99 | **FREE** |
| `NOCOST_DIR` | 100% OFF | Directory Submission | $6.99 | **FREE** |

**Valid Until**: January 30, 2026  
**Usage**: One-time per account

---

## API Endpoints Quick Reference

### 1. Validate Coupon
```
POST /api/coupon/validate
Headers: Authorization: Bearer <token>
Body: { "couponCode": "NOCOST", "serviceType": "websiteSubmission" }
```

### 2. Apply Coupon
```
POST /api/coupon/apply
Headers: Authorization: Bearer <token>
Body: { "couponCode": "NOCOST", "serviceType": "websiteSubmission" }
```

### 3. Get My Used Coupons
```
GET /api/coupon/my-coupons
Headers: Authorization: Bearer <token>
```

### 4. Create Coupon (Admin)
```
POST /api/coupon/create
Body: { code, discountType, discountAmount, serviceType, validUntil, maxUsage }
```

---

## Service Types

- `websiteSubmission` - Website submission ($12.99)
- `aiWebsite` - AI website submission ($12.99)
- `directory` - Directory submission ($6.99)
- `jobPost` - Job post ($15.99)

---

## Implementation Flow

1. **User enters coupon code**
2. **Frontend validates** → `POST /api/coupon/validate`
3. **Show discounted price** to user
4. **User confirms and pays** (if not 100% off)
5. **Backend applies coupon** → `POST /api/coupon/apply`
6. **Mark as used** in User and Coupon models
7. **Complete submission**

---

## Key Features

✅ One-time use per user account  
✅ Service-specific validation  
✅ Automatic expiration checking  
✅ Global usage limits  
✅ Tracks usage history  
✅ Prevents duplicate usage  

---

## Testing Commands

### Test Validate Coupon
```bash
curl -X POST http://localhost:5000/api/coupon/validate \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"couponCode": "NOCOST", "serviceType": "websiteSubmission"}'
```

### Test Apply Coupon
```bash
curl -X POST http://localhost:5000/api/coupon/apply \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_TOKEN" \
  -d '{"couponCode": "NOCOST", "serviceType": "websiteSubmission"}'
```

### Get Used Coupons
```bash
curl -X GET http://localhost:5000/api/coupon/my-coupons \
  -H "Authorization: Bearer YOUR_TOKEN"
```

---

## Setup

Run once to create coupons:
```bash
cd Backend/Backend
node create-coupons.js
```

✅ Coupons created successfully!
