# POS Gateway Phase 0 Execution Pack

Tanggal: 2026-04-09

## Tujuan

Menyiapkan fondasi teknis `POS Gateway` tanpa mengubah endpoint pyPOS lama.

## Scope yang Sudah Dibuat

1. Konfigurasi gateway (default OFF).
2. Skeleton controller gateway baru.
3. Skeleton plugin connector pyPOS.
4. Service ingest canonical + model inbox/registry/binding.
5. SQL schema draft untuk tabel baru.

## File Baru

### Config

- `application/config/pos_gateway.php`

### Controller Baru (tidak menggantikan endpoint lama)

- `application/controllers/pos_gateway/PosGatewayApi.php`
- `application/controllers/pos_gateway/PosGatewayStatus.php`

### Library POS Gateway

- `application/libraries/PosGateway/ConnectorInterface.php`
- `application/libraries/PosGateway/ConnectorResolver.php`
- `application/libraries/PosGateway/Connectors/PyPosConnector.php`
- `application/libraries/PosGateway/CanonicalIngestService.php`

### Model Baru

- `application/models/MdlPosGatewayInbox.php`
- `application/models/MdlPosGatewayRegistry.php`
- `application/models/MdlPosGatewayBinding.php`

### SQL

- `docs/sql/POS_GATEWAY_PHASE0_SCHEMA_2026-04-09.sql`

## Cara Aktivasi Bertahap (Staging Dulu)

1. Jalankan SQL schema di staging.
2. Set config `pos_gateway_enabled = true` hanya di staging.
3. Uji endpoint baru:
   - `.../pos_gateway/PosGatewayApi/ingest`
   - `.../pos_gateway/PosGatewayStatus/query`
4. Endpoint lama tetap dipakai normal (belum reroute).

## Contoh Request Minimum (Staging)

```json
{
  "provider_code": "pypos",
  "event_type": "sales_batch",
  "tenant_id": "SBG01",
  "cabang_id": 12,
  "machine_id": "118933446257318",
  "file_hash": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
  "payload": {
    "example": "phase0"
  }
}
```

## Catatan Penting

1. Ini baru pondasi ingest; dispatch worker bisnis belum diaktifkan.
2. Endpoint lama pyPOS belum diubah sama sekali.
3. Config default OFF untuk mencegah aktivasi tidak sengaja di production.

## Next Step (Phase 1)

1. Tambah event dispatcher worker internal.
2. Tambah facade method di endpoint lama untuk forward ke gateway service (tetap kompatibel response lama).
3. Tambah contract tests upload + settlement + sync.

Status update:

- Facade endpoint lama sudah disiapkan pada dokumen `docs/POS_GATEWAY_PHASE1_LEGACY_FACADE_2026-04-09.md`.
