## Requirements

# 4. Requirements

## 4.1 Functional Requirements

### 4.1.1 Order Service

- The system shall support creation of a single order per API request. Bulk or batch order creation is not supported in the current implementation.  
  [KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-4c9591c9-34d5-42b1-a0e2-1de20131159c], [KB-86e313b9-691a-4830-b560-a2097e138f34]

- The system shall calculate the total order amount automatically based on the sum of (quantity × unit price) for each item.  
  [KB-0e0f1dd0-0f46-4d13-a092-e3cdc6fdd205], [KB-86e313b9-691a-4830-b560-a2097e138f34]

- The system shall provide paginated listing of orders with parameters: skip (default 0), limit (default 20).  
  [KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-4287fde1-e2d9-4e31-8f2f-5c3f64f00add]

- The system shall allow retrieval of order details by order ID, including item details.  
  [KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-4c9591c9-34d5-42b1-a0e2-1de20131159c]

- The system shall support order status transitions: PENDING → PROCESSING → PAID → SHIPPED → DELIVERED.  
  [KB-55d6e023-2c8e-49db-9409-68b9e9ed721f]

- The system shall support order cancellation, updating the status to CANCELLED.  
  [KB-55d6e023-2c8e-49db-9409-68b9e9ed721f], [KB-981308db-2c30-4894-ba6b-491bf40b1d24]

### 4.1.2 Payment Service

- The system shall process payment for a single order per API request. Batch payment processing is not supported.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-9b61fb5a-8a89-4024-a535-ca56b147a8c8], [KB-8ca26148-03e1-4184-a736-624e14448df9]

- Payment amount must be validated: minimum 100 JPY, maximum 1,000,000 JPY per transaction.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6]

- Payment requests with duplicate order IDs (payment already exists) must be rejected.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

- Payment Service notifies Order Service of payment status via webhook callback for each individual order.  
  [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6], [KB-69d55b34-e506-4b4e-a043-ef842030f397], [KB-4bd8168d-aed4-41eb-8733-2ab9d82daa22]

- Refund processing is supported for completed payments; refund requests are sent to Payment Service when an order is cancelled.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-981308db-2c30-4894-ba6b-491bf40b1d24], [KB-186b33d7-f985-455b-8117-0cd019912510]

### 4.1.3 Notification Service

- The system shall send email notifications for individual orders using templates.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8], [KB-582e7673-bd66-493e-b511-017708ae9326]

- The system shall send SMS notifications for individual orders using templates.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8], [KB-2414677b-6e22-47f5-917c-2ed718d86fd4]

- The system shall support three notification templates: ORDER_CONFIRMATION, ORDER_SHIPPED, ORDER_CANCELLED.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

- Templates shall support Jinja2-style variable substitution with Japanese language content.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8], [KB-3133bf0e-2d7b-4477-9e36-c8548c037b2c]

- The system shall track notification delivery status (PENDING, SENT, FAILED).  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

- The system shall retrieve notification history by notification ID and retrieve all notifications for a specific order.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8], [KB-4d364408-238b-4248-925a-97d5a3446d3c]

- Notification Service API rate limit: 10 requests per second for email notifications.  
  [KB-582e7673-bd66-493e-b511-017708ae9326]

### 4.1.4 Bulk Operations (CSV Import)

[GAP: Missing data for Requirements]  
*Bulk CSV import functionality is not implemented in the current system. Multiple knowledge base entries indicate business requirements and user demand for bulk import (100–10,000 orders via CSV), but the actual feature is not available. CSV import buttons are disabled and display "CSVインポート（未実装）".*  
[KB-16181d30-2dd3-421e-bab0-939cd85255d2], [KB-94407aa3-d1ac-4455-a68c-265236fefec4], [KB-6ef0a78b-63b6-493a-a7b0-76398d5a2889]

## 4.2 Interface Requirements

### 4.2.1 API Endpoints

#### Order Service

| Endpoint                              | Method | Description                                  |
|----------------------------------------|--------|----------------------------------------------|
| /api/v1/orders/                        | POST   | Create single order                          |
| /api/v1/orders/                        | GET    | List orders (pagination: skip, limit)        |
| /api/v1/orders/{order_id}              | GET    | Get order details                            |
| /api/v1/orders/{order_id}/status       | PUT    | Update order status                          |
| /api/v1/orders/{order_id}              | DELETE | Cancel order; triggers refund and notification|
| /api/v1/orders/{order_id}/webhook      | POST   | Payment status update (single order)         |

[KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-4287fde1-e2d9-4e31-8f2f-5c3f64f00add], [KB-69d55b34-e506-4b4e-a043-ef842030f397]

#### Payment Service

| Endpoint                              | Method | Description                                  |
|----------------------------------------|--------|----------------------------------------------|
| /api/v1/payments/                      | POST   | Process payment for single order             |
| /api/v1/payments/{payment_id}          | GET    | Retrieve payment details                     |
| /api/v1/payments/order/{order_id}      | GET    | Retrieve payment for specific order          |
| /api/v1/payments/refund                | POST   | Process refund for completed payment         |

[KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-186b33d7-f985-455b-8117-0cd019912510]

#### Notification Service

| Endpoint                              | Method | Description                                  |
|----------------------------------------|--------|----------------------------------------------|
| /api/v1/notifications/email            | POST   | Send single email notification (rate limited)|
| /api/v1/notifications/sms              | POST   | Send single SMS notification                 |
| /api/v1/notifications/{notification_id}| GET    | Retrieve notification history by ID          |
| /api/v1/notifications/order/{order_id} | GET    | Retrieve all notifications for an order      |

[KB-582e7673-bd66-493e-b511-017708ae9326], [KB-2414677b-6e22-47f5-917c-2ed718d86fd4], [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

## 4.3 Constraint Requirements

- Payment processing is limited to one order per transaction; batch payment processing is not supported.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6]

- Maximum payment amount per transaction is 1,000,000 JPY; minimum is 100 JPY.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6]

- Duplicate payment requests for the same order ID are rejected.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

- Webhook notifications for payment status are performed per order; batch webhook or batch status update is not available.  
  [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6], [KB-69d55b34-e506-4b4e-a043-ef842030f397]

- Notification Service API is rate limited to 10 requests per second for email notifications.  
  [KB-582e7673-bd66-493e-b511-017708ae9326]

## 4.4 Data Requirements

- Order data includes: customer name, customer email, item details (product name, quantity, unit price), total amount, currency, status, timestamps, and itemized list.  
  [KB-1bfa4181-74da-4372-ba8f-acf6d7aa41c4], [KB-4c9591c9-34d5-42b1-a0e2-1de20131159c]

- Payment data includes: order ID, amount, currency, status, payment method, transaction ID, timestamps.  
  [KB-90c1a181-8f6a-4efe-be94-d7a6c0e37f5a]

- Notification data includes: order ID, channel (email/SMS), template name, recipient, subject, body, status, timestamps.  
  [KB-258b5996-5aad-4f5f-acd2-8e458c49f884]

## 4.5 Business Requirements

- There is documented demand from corporate customers for bulk order import (100–10,000 orders via CSV file) to improve operational efficiency.  
  [KB-94407aa3-d1ac-4455-a68c-265236fefec4], [KB-6ef0a78b-63b6-493a-a7b0-76398d5a2889], [KB-16181d30-2dd3-421e-bab0-939cd85255d2]

- The current system does not implement bulk CSV import functionality; only single order creation is supported.  
  [KB-16181d30-2dd3-421e-bab0-939cd85255d2]

---

*This section is ISO-29148 compliant and strictly based on the provided knowledge base context. No external information or assumptions have been included.*