# RP Learning Portal — Frontend API Contracts

**Version:** 1.0 — Pre-Phase 10  
**Date:** 2026-06-12  
**Status:** Frontend expectations only — NOT real APIs

---

## Purpose

These contracts define what the frontend expects from each Phase 10–15 endpoint. They are NOT real APIs — they are frontend expectations that will accelerate backend integration when Phase 10 15 is completed.

---

## Phase 10 — Finance

### Invoice List (Parent)

**Screen:** PAR-08  
**Expected Endpoint:** `GET /api/parent/invoices`  
**Expected Payload:**
```json
{
  "data": [
    {
      "id": 1,
      "invoice_number": "INV-2026-0001",
      "student_name": "Amara Asante",
      "amount": 2500.00,
      "currency": "GHS",
      "status": "sent",
      "due_date": "2026-07-01",
      "items": [
        { "description": "Tuition Fee", "amount": 2000.00 },
        { "description": "Library Fee", "amount": 500.00 }
      ]
    }
  ],
  "meta": { "total": 5, "page": 1, "per_page": 15 }
}
```

### Invoice Detail (Parent)

**Screen:** PAR-09  
**Expected Endpoint:** `GET /api/parent/invoices/{id}`  
**Expected Payload:**
```json
{
  "data": {
    "id": 1,
    "invoice_number": "INV-2026-0001",
    "student_name": "Amara Asante",
    "parent_name": "Kwame Asante",
    "subtotal": 2500.00,
    "discount_amount": 0.00,
    "total_amount": 2500.00,
       "currency": "GHS",
    "status": "sent",
    "due_date": "2026-07-01",
    "items": [
      { "description": "Tuition Fee", "unit_amount": 2000.00, "quantity": 1, "line_total": 2000.00 },
      { "description": "Library Fee", "unit_amount": 500.00, "quantity": 1, "line_total": 500.00 }
    ],
    "payments": [],
    "balance_remaining": 2500.00
  }
}
```

### Initialize Payment

**Screen:** PAR-10  
**Expected Endpoint:** `POST /api/parent/invoices/{id}/pay`  
**Expected Payload:**
```json
{
  "invoice_id": 1,
  "amount": 2500.00,
  "payment_method": "card",
  "email": "parent@example.com"
}
```
**Expected Response:**
```json
{
  "data": {
    "reference": "RP-2026-0001",
    "access_code": "abc123",
    "authorization_url": "https://checkout.paystack.com/abc123"
  }
}
``