## Requirements

# 4. Requirements

## 4.1 Functional Requirements

### 4.1.1 Order Service

- The system shall allow creation of a single order per request, specifying customer information (name, email), order items (product name, quantity, unit price), and currency. Bulk or batch creation is not supported.  
  [KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-4c9591c9-34d5-42b1-a0e2-1de20131159c]

- The system shall automatically calculate the total order amount as the sum of (quantity × unit price) for each item.  
  [KB-0e0f1dd0-0f46-4d13-a092-e3cdc6fdd205]

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

- The system shall allow retrieval of order details by order ID, including item details.  
  [KB-55d6e023-2c8e-49db-9409-68b9e9ed721f]

- The system shall support order status transitions: PENDING → PROCESSING PAYMENT → 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]

### 4.1.2 Payment Service

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

- Payment amount must be between 100 JPY and 1,000,000 JPY per transaction.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

- Each order can only have one payment (1:1 relationship). Duplicate payment requests for the same order are rejected.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

- The system shall support refund processing for completed payments.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

- After payment processing, Payment Service shall notify Order Service of payment status via webhook callback (single-order only).  
  [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6], [KB-69d55b34-e506-4b4e-a043-ef842030f397]

### 4.1.3 Notification Service

- The system shall send email notifications for individual orders using templates.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

- The system shall send SMS notifications for individual orders using templates.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

- 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]

- 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.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

- The system shall retrieve all notifications for a specific order.  
  [KB-6155f440-0799-44eb-851f-9a5b81fbbcf8]

### 4.1.4 CSV Import (Bulk Order)

- The system shall allow users to upload CSV files for bulk order import. Maximum file size: 50MB. Supported encodings: UTF-8, Shift_JIS.  
  [KB-063a89e7-bb79-4435-993b-95ec7b9a9e4e]

- The system shall validate CSV structure, data types, and required fields. Errors must be reported with row-level detail.  
  [KB-2d968f58-3ed8-4207-9d71-0c429c197cb4], [KB-35c9e00d-f446-4174-be65-d214ecbff895]

- The system shall create orders in bulk from validated CSV data, supporting 100 to 10,000 orders per import.  
  [KB-35c9e00d-f446-4174-be65-d214ecbff895]

- The system shall process payments for all created orders individually (no batch payment endpoint).  
  [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6]

- The system shall send confirmation emails in bulk to all order recipients, considering rate limits.  
  [KB-1b4a5120-e114-4bb2-b423-43e981424088]

- The system shall display real-time progress tracking during import (processed/total count).  
  [KB-0e28e3cb-6977-43b1-ba8e-1ed80f2de11e]

- The system shall handle partial failures: successful orders are retained, failed orders are listed and downloadable.  
  [KB-0e28e3cb-6977-43b1-ba8e-1ed80f2de11e]

- The system shall allow download of a correct CSV template for import.  
  [KB-89dddd9a-2e13-46e7-99a4-34c3f7e18140b]

- The system shall allow cancellation of in-progress imports; unprocessed orders are not created.  
  [KB-89dddd9a-2e13-46e7-99a4-34c3f7e18140b]

- The system shall display import history, including filename, count, success/failure, executor, and timestamp.  
  [KB-89dddd9a-2e13-46e7-99a4-34c3f7e18140b]

## 4.2 Constraints

- Only single order creation, payment, and notification per API request; batch endpoints are not supported.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-582e7673-bd66-493e-b511-017708ae9326]

- Payment amount must be between 100 JPY and 1,000,000 JPY per transaction.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

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

- Refund processing is only allowed for completed payments.  
  [KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-299da2e5-721b-4ab1-9bb0-cd2d0f03c8c6]

- Notification Service rate limit: 10 emails per second.  
  [KB-582e7673-bd66-493e-b511-017708ae9326]

- Bulk payment processing is not supported; each order requires a separate payment API call.  
  [KB-564ae239-84b1-4ef2-bb04-b7e829eb53b6]

## 4.3 Business Requirements

- The system shall support operational efficiency for corporate customers by enabling bulk order import (100–10,000 orders) via CSV.  
  [KB-155b5f4a-d232-4166-bb96-ba158f86ceb1], [KB-1603dccf-0e13-426d-a4c3-527af9e69c16], [KB-2183809f-cfa9-4b0b-a30d-320f78a4f161], [KB-2b0238e6-fb8b-4b64-bbb0-73de35f73a08], [KB-2b07b017-3e2f-47a4-9b03-d2be4a0e5644], [KB-5bd83fdc-f7d5-4953-bd1e-e9b287f0bf96], [KB-94407aa3-d1ac-4455-a68c-265236fefec4], [KB-9722c127-de97-4494-bb8d-1d840efa8899], [KB-5a963d29-d4ed-4859-ba71-d355620aa5bc], [KB-6ef0a78b-63b6-493a-a7b0-76398d5a2889]

- The system shall support tracking and reporting of import history for audit and operational review.  
  [KB-89dddd9a-2e13-46e7-99a4-34c3f7e18140b]

## 4.4 Interface Requirements

### 4.4.1 Order Service API

| Endpoint                                 | Description                                 | Notes                                      |
|-------------------------------------------|---------------------------------------------|--------------------------------------------|
| POST /api/v1/orders/                      | Create single order                         | No bulk/batch creation                     |
| GET /api/v1/orders/                       | List orders (pagination: skip, limit)       | Default limit: 20                          |
| GET /api/v1/orders/{order_id}             | Retrieve order details                      | Includes item details                      |
| PUT /api/v1/orders/{order_id}/status      | Update order status                         | SHIPPED triggers shipping notification      |
| DELETE /api/v1/orders/{order_id}          | Cancel order                                | Triggers refund and cancellation email      |
| POST /api/v1/orders/{order_id}/webhook    | Payment status update (single order)        | No batch webhook/status update              |

[KB-4287fde1-e2d9-4e31-8f2f-5c3f64f00add], [KB-459cbd85-fb6b-4a7e-8a36-e5f711cac6b9], [KB-981308db-2c30-4894-ba6b-491bf40b1d24], [KB-69d55b34-e506-4b4e-a043-ef842030f397]

### 4.4.2 Payment Service API

| Endpoint                                 | Description                                 | Notes                                      |
|-------------------------------------------|---------------------------------------------|--------------------------------------------|
| POST /api/v1/payments/                    | Process payment for single order            | Amount validation, duplicate check         |
| GET /api/v1/payments/{payment_id}         | Retrieve payment by payment ID              |                                            |
| GET /api/v1/payments/order/{order_id}     | Retrieve payment for specific order         | 1:1 relationship                          |
| POST /api/v1/payments/refund              | Process refund for completed payment        |                                            |

[KB-8072a75f-d61d-49b1-a859-1be86806c449], [KB-36050440-5a8a-4389-8690-8fd0a46f5cd3], [KB-8e5c6600-75fa-4e87-a6f5-0d06b21d8625], [KB-90c1a181-8f6a-4efe-be94-d7a6c0e37f5a]

### 4.4.3 Notification Service API

| Endpoint                                         | Description                                 | Notes                                      |
|--------------------------------------------------|---------------------------------------------|--------------------------------------------|
| POST /api/v1/notifications/email                 | Send single email notification               | Rate limit: 10/sec                         |
| POST /api/v1/notifications/sms                   | Send single SMS notification                 |                                            |
| GET /api/v1/notifications/{notification_id}      | Retrieve notification by ID                  |                                            |
| GET /api/v1/notifications/order/{order_id}       | Retrieve all notifications for an order      |                                            |

[KB-582e7673-bd66-493e-b511-017708ae9326], [KB-2414677b-6e22-47f5-917c-2ed718d86fd4]

## 4.5 Data Requirements

- CSV file upload for bulk order import: maximum 50MB, UTF-8 or Shift_JIS encoding.  
  [KB-063a89e7-bb79-4435-993b-95ec7b9a9e4e], [KB-2d968f58-3ed8-4207-9d71-0c429c197cb4]

- CSV validation must include structure, data types, and required fields; errors reported at row level.  
  [KB-2d968f58-3ed8-4207-9d71-0c429c197cb4], [KB-35c9e00d-f446-4174-be65-d214ecbff895]

- Import history must include filename, count, success/failure, executor, and timestamp.  
  [KB-89dddd9a-2e13-46e7-99a4-34c3f7e18140b]

## 4.6 Performance Requirements

- Bulk order creation: up to 10,000 orders must be created within 5 minutes.  
  [KB-35c9e00d-f446-4174-be65-d214ecbff895]

## 4.7 [GAP: Missing data for Requirements]

If additional requirements are needed (e.g., for security, audit, error handling, etc.), please refer to the relevant context blocks or specify the requirements.

---

**All requirements are derived strictly from the provided context. No external assumptions or generic content have been included.**