# Features & Integrations

### 1. Three-Level Referral System

**Purpose**: Incentivize user acquisition through multi-level referral bonuses.

**Structure:**
- Level 1: 20% bonus from product price
- Level 2: 20% bonus from product price
- Level 3: 20% bonus from product price

**Implementation:**
- See `REFERRAL_SYSTEM_README.md` for complete details
- Automatic bonus distribution on purchase
- Tax calculation (2.5% on bonuses)

### 2. Payment Gateway - Xendit

**Supported Payment Methods:**
- Virtual Accounts (BCA, BNI, BRI, Mandiri, Permata)
- E-wallets (OVO, Dana, LinkAja)
- Credit/Debit Cards
- Retail Outlets (Alfamart, Indomaret)

**Flow:**
1. Create payment request via Xendit API
2. Return payment instructions to user
3. Receive webhook on payment success
4. Update order status automatically

**Files:**
- `controller/virtualAccount/virtual_account.controller.js`
- `controller/webhook.controller.js`

### 3. File Upload & Media Processing

**Supported Operations:**
- Image upload (products, reviews, banners)
- Image compression with Sharp
- Video processing with FFmpeg
- PDF generation
- Barcode generation
- Minio object storage

**Configuration:**
- Max 20 images per product
- Image compression for web optimization
- Temporary file cleanup

### 4. Email Notifications

**Triggers:**
- Order confirmation
- Payment received
- Shipment confirmed
- Order delivered
- Review reminders

**Configuration:**
```javascript
// In utility/email_util.js
const transporter = nodemailer.createTransport({
  host: process.env.EMAIL_HOST,
  port: process.env.EMAIL_PORT,
  auth: {
    user: process.env.EMAIL_USER,
    pass: process.env.EMAIL_PASSWORD
  }
});
```

### 5. WhatsApp API Integration

**Features:**
- Order notifications
- Payment reminders
- Promotional messages

**Files:**
- `utility/whatsappapi.js`