118 lines
3.6 KiB
Markdown
118 lines
3.6 KiB
Markdown
|
|
# External API Migration - Progress
|
||
|
|
|
||
|
|
## Status: ✅ MIGRATED
|
||
|
|
|
||
|
|
Semua external API yang masih dipakai telah dimigrasikan ke Slim 4.
|
||
|
|
|
||
|
|
## Endpoint yang Sudah Dimigrasikan
|
||
|
|
|
||
|
|
### 1. Api Controller (`/api/`)
|
||
|
|
- ✅ `GET /api/mandiri/{tanggal}` - Data catat meter Mandiri
|
||
|
|
|
||
|
|
### 2. Fast Controller (`/fast/`)
|
||
|
|
- ✅ `GET /fast/test` - Test endpoint (no auth)
|
||
|
|
- ✅ `POST /fast/check_bill` - Cek tagihan PDAM (with API Key)
|
||
|
|
- ✅ `POST /fast/process_payment` - Proses pembayaran (with API Key)
|
||
|
|
- ✅ `GET /fast/process_payment_get` - Proses pembayaran via GET (with API Key)
|
||
|
|
- ✅ `GET /fast/payment_status` - Cek status pembayaran (with API Key)
|
||
|
|
- ✅ `POST /fast/payment_status` - Cek status pembayaran (with API Key)
|
||
|
|
- ✅ `GET /fast/check_wipay_saldo` - Cek saldo WIPAY (with API Key)
|
||
|
|
- ✅ `POST /fast/check_wipay_saldo` - Cek saldo WIPAY (with API Key)
|
||
|
|
- ✅ `GET /fast/check_wipay_saldo_get` - Cek saldo WIPAY via GET (with API Key)
|
||
|
|
- ✅ `GET /fast/mandiri/{tanggal}` - Data Mandiri
|
||
|
|
|
||
|
|
### 3. Site Controller (`/site/`)
|
||
|
|
- ✅ `POST /site/verify_bri` - Verifikasi pembayaran BRI
|
||
|
|
- ✅ `POST /site/approve/{id_trx}` - Approve transaksi
|
||
|
|
|
||
|
|
## File yang Dibuat
|
||
|
|
|
||
|
|
### Models
|
||
|
|
- `src/Models/ApiKeyModel.php` - Model untuk API key management
|
||
|
|
|
||
|
|
### Middleware
|
||
|
|
- `src/Middleware/ApiKeyMiddleware.php` - Middleware untuk API key authentication
|
||
|
|
|
||
|
|
### Controllers
|
||
|
|
- `src/Controllers/ApiController.php` - Controller untuk API mandiri
|
||
|
|
- `src/Controllers/FastController.php` - Controller untuk Fast WIPAY API
|
||
|
|
- `src/Controllers/SiteController.php` - Controller untuk Site (admin) API
|
||
|
|
|
||
|
|
## Authentication
|
||
|
|
|
||
|
|
### API Key Authentication
|
||
|
|
- Header: `X-Client-ID` dan `X-Client-Secret`
|
||
|
|
- Atau via query params: `client_id` dan `client_secret`
|
||
|
|
- Atau via body: `client_id` dan `client_secret`
|
||
|
|
|
||
|
|
### Endpoint yang Tidak Perlu Auth
|
||
|
|
- `GET /api/mandiri/{tanggal}` - Public
|
||
|
|
- `GET /fast/test` - Public
|
||
|
|
- `GET /fast/mandiri/{tanggal}` - Public
|
||
|
|
|
||
|
|
## Database Tables
|
||
|
|
|
||
|
|
External API menggunakan tabel:
|
||
|
|
- `api_keys` - Untuk menyimpan API key
|
||
|
|
- `api_logs` - Untuk logging API usage
|
||
|
|
- `admin_users` - Untuk admin user data
|
||
|
|
- `pengguna_timo` - User data
|
||
|
|
- `wipay_pengguna` - WIPAY user data
|
||
|
|
- `wipay_mutasi` - WIPAY transaction history
|
||
|
|
- `pembayaran` - Payment records
|
||
|
|
- `catat_meter` - Meter reading data
|
||
|
|
|
||
|
|
## Environment Variables
|
||
|
|
|
||
|
|
Tambahkan ke `.env`:
|
||
|
|
```
|
||
|
|
BASE_URL=http://localhost:8000
|
||
|
|
|
||
|
|
# BRI Integration (untuk Site API)
|
||
|
|
BRI_KEY=your_bri_key
|
||
|
|
BRI_SECRET=your_bri_secret
|
||
|
|
BRI_URL_TOKEN=https://api.bri.co.id/oauth/token
|
||
|
|
BRI_URL_MUTASI=https://api.bri.co.id/v2.0/statement
|
||
|
|
BRI_REKENING=your_bri_account_number
|
||
|
|
```
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
### Test API Mandiri
|
||
|
|
```bash
|
||
|
|
curl http://localhost:8000/api/mandiri/10112024
|
||
|
|
```
|
||
|
|
|
||
|
|
### Test Fast API (dengan API Key)
|
||
|
|
```bash
|
||
|
|
curl -X GET http://localhost:8000/fast/test
|
||
|
|
|
||
|
|
curl -X POST http://localhost:8000/fast/check_bill \
|
||
|
|
-H "X-Client-ID: your_client_id" \
|
||
|
|
-H "X-Client-Secret: your_client_secret" \
|
||
|
|
-H "Content-Type: application/json" \
|
||
|
|
-d '{"no_sl":"059912"}'
|
||
|
|
```
|
||
|
|
|
||
|
|
### Test Site API
|
||
|
|
```bash
|
||
|
|
curl -X POST http://localhost:8000/site/verify_bri
|
||
|
|
|
||
|
|
curl -X POST http://localhost:8000/site/approve/1
|
||
|
|
```
|
||
|
|
|
||
|
|
## Catatan
|
||
|
|
|
||
|
|
1. **API Key Management**: Pastikan tabel `api_keys` dan `api_logs` ada di database
|
||
|
|
2. **BRI Integration**: Site API memerlukan konfigurasi BRI di `.env`
|
||
|
|
3. **CORS**: Semua external API sudah support CORS
|
||
|
|
4. **Response Format**: Fast API menggunakan format `{status: 'success/error', message: '...', data: {...}}`
|
||
|
|
5. **Api Mandiri**: Menggunakan format khusus `{status: 1, date: '...', data: [...]}`
|
||
|
|
|
||
|
|
## Next Steps
|
||
|
|
|
||
|
|
1. Test semua endpoint dengan data real
|
||
|
|
2. Setup API keys di database
|
||
|
|
3. Konfigurasi BRI credentials di `.env`
|
||
|
|
4. Test dengan client yang menggunakan API ini
|