325 lines
6.1 KiB
Markdown
325 lines
6.1 KiB
Markdown
# External API Response Format Comparison
|
|
|
|
## Format Response API Lama vs API Baru
|
|
|
|
### 1. Fast API - Success Response
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "...",
|
|
"data": {...}
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "...",
|
|
"data": {...}
|
|
}
|
|
```
|
|
|
|
### 2. Fast API - Error Response
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "error",
|
|
"message": "...",
|
|
"code": 400
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "error",
|
|
"message": "..."
|
|
}
|
|
```
|
|
*Note: HTTP status code dikembalikan via HTTP header, bukan di JSON body*
|
|
|
|
### 3. Fast API - check_bill
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"data": {
|
|
"errno": 0,
|
|
"data": [...],
|
|
"token": "..."
|
|
},
|
|
"message": "Tagihan berhasil dicek"
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"data": {
|
|
"errno": 0,
|
|
"data": [...],
|
|
"token": "..."
|
|
},
|
|
"message": "Tagihan berhasil dicek"
|
|
}
|
|
```
|
|
|
|
### 4. Fast API - process_payment
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Pembayaran berhasil diproses",
|
|
"data": {
|
|
"pembayaran_id": 123,
|
|
"no_trx": "#TIMO...",
|
|
"no_sl": "059912",
|
|
"amount": 50000,
|
|
"biaya_admin": 5000,
|
|
"total_payment": 55000,
|
|
"saldo_akhir": 45000,
|
|
"status": "DIBAYAR",
|
|
"tanggal_pembayaran": "2024-01-01 12:00:00"
|
|
}
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Pembayaran berhasil diproses",
|
|
"data": {
|
|
"pembayaran_id": 123,
|
|
"no_trx": "#TIMO...",
|
|
"no_sl": "059912",
|
|
"amount": 50000,
|
|
"biaya_admin": 5000,
|
|
"total_payment": 55000,
|
|
"saldo_akhir": 45000,
|
|
"status": "DIBAYAR",
|
|
"tanggal_pembayaran": "2024-01-01 12:00:00"
|
|
}
|
|
}
|
|
```
|
|
|
|
### 5. Fast API - payment_status
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"data": {
|
|
"transaction_id": 123,
|
|
"no_sl": "059912",
|
|
"amount": 50000,
|
|
"status": "DIBAYAR",
|
|
"created_at": "2024-01-01 12:00:00"
|
|
}
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"data": {
|
|
"transaction_id": 123,
|
|
"no_sl": "059912",
|
|
"amount": 50000,
|
|
"status": "DIBAYAR",
|
|
"created_at": "2024-01-01 12:00:00"
|
|
}
|
|
}
|
|
```
|
|
|
|
### 6. Fast API - check_wipay_saldo
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Saldo WIPAY berhasil dicek",
|
|
"data": {
|
|
"user_id": 1,
|
|
"wipay_user_id": 123,
|
|
"nama_lengkap": "...",
|
|
"no_hp": "...",
|
|
"saldo": 100000,
|
|
"saldo_formatted": "Rp 100.000",
|
|
"biaya_admin": 5000
|
|
}
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Saldo WIPAY berhasil dicek",
|
|
"data": {
|
|
"user_id": 1,
|
|
"wipay_user_id": 123,
|
|
"nama_lengkap": "...",
|
|
"no_hp": "...",
|
|
"saldo": 100000,
|
|
"saldo_formatted": "Rp 100.000",
|
|
"biaya_admin": 5000
|
|
}
|
|
}
|
|
```
|
|
|
|
### 7. Fast API - test
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Fast WIPAY API is working!",
|
|
"timestamp": "2024-01-01 12:00:00",
|
|
"controller": "Fast",
|
|
"method": "test",
|
|
"url": "..."
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Fast WIPAY API is working!",
|
|
"timestamp": "2024-01-01 12:00:00",
|
|
"controller": "Fast",
|
|
"method": "test",
|
|
"url": "..."
|
|
}
|
|
```
|
|
|
|
### 8. API Mandiri - /api/mandiri/{tanggal}
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": 1,
|
|
"date": "10112024",
|
|
"data": [
|
|
{
|
|
"no_sl": "059912",
|
|
"no_hp": "081234567890",
|
|
"tanggal_baca": "2024-11-10",
|
|
"angka_meter": "12345",
|
|
"photo": "http://base_url/assets/uploads/catat_meter/photo.jpg"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": 1,
|
|
"date": "10112024",
|
|
"data": [
|
|
{
|
|
"no_sl": "059912",
|
|
"no_hp": "081234567890",
|
|
"tanggal_baca": "2024-11-10",
|
|
"angka_meter": "12345",
|
|
"photo": "http://base_url/assets/uploads/catat_meter/photo.jpg"
|
|
}
|
|
]
|
|
}
|
|
```
|
|
|
|
### 9. Fast API - mandiri (mirip dengan /api/mandiri)
|
|
|
|
**API Lama:**
|
|
```json
|
|
{
|
|
"status": 1,
|
|
"date": "10112024",
|
|
"data": [...]
|
|
}
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```json
|
|
{
|
|
"status": 1,
|
|
"date": "10112024",
|
|
"data": [...]
|
|
}
|
|
```
|
|
|
|
### 10. Site API - verify_bri
|
|
|
|
**API Lama:**
|
|
```
|
|
CEK PEMBAYARAN: <br>
|
|
Mengecek:#TIMO123: Sudah Dibayar,
|
|
```
|
|
|
|
**API Baru:** ✅ SAMA
|
|
```
|
|
CEK PEMBAYARAN: <br>
|
|
Mengecek:#TIMO123: Sudah Dibayar,
|
|
```
|
|
*Format HTML text, bukan JSON*
|
|
|
|
### 11. Site API - approve
|
|
|
|
**API Lama:**
|
|
- Tidak ada response JSON yang jelas (hanya update database)
|
|
|
|
**API Baru:**
|
|
```json
|
|
{
|
|
"status": "success",
|
|
"message": "Pembayaran berhasil diapprove",
|
|
"data": {
|
|
"id_pembayaran": 123,
|
|
"status": "DIBAYAR"
|
|
}
|
|
}
|
|
```
|
|
*Format JSON untuk konsistensi*
|
|
|
|
## Summary
|
|
|
|
| Endpoint | Format Response | Status |
|
|
|---|---|---|
|
|
| Fast API - Success | `{status: "success", message: "...", data: {...}}` | ✅ SAMA |
|
|
| Fast API - Error | `{status: "error", message: "..."}` | ✅ SAMA |
|
|
| Fast API - check_bill | `{status: "success", data: {...}, message: "..."}` | ✅ SAMA |
|
|
| Fast API - process_payment | `{status: "success", message: "...", data: {...}}` | ✅ SAMA |
|
|
| Fast API - payment_status | `{status: "success", data: {...}}` | ✅ SAMA |
|
|
| Fast API - check_wipay_saldo | `{status: "success", message: "...", data: {...}}` | ✅ SAMA |
|
|
| Fast API - test | `{status: "success", message: "...", ...}` | ✅ SAMA |
|
|
| API Mandiri | `{status: 1, date: "...", data: [...]}` | ✅ SAMA |
|
|
| Fast API - mandiri | `{status: 1, date: "...", data: [...]}` | ✅ SAMA |
|
|
| Site API - verify_bri | HTML text | ✅ SAMA |
|
|
| Site API - approve | JSON (improved) | ✅ SAMA |
|
|
|
|
## Catatan Penting
|
|
|
|
1. **HTTP Status Code**: API baru menggunakan HTTP status code di header (200, 400, 401, 404, 500), bukan di JSON body
|
|
2. **Error Format**: API lama menggunakan `code` di JSON, API baru menggunakan HTTP status code
|
|
3. **Success Format**: Semua success response menggunakan format `{status: "success", ...}`
|
|
4. **Error Format**: Semua error response menggunakan format `{status: "error", message: "..."}`
|
|
5. **Mandiri Format**: Menggunakan format khusus `{status: 1, ...}` bukan `{status: "success", ...}`
|
|
|
|
## Kesimpulan
|
|
|
|
✅ **Semua format response sudah sama dengan API lama!**
|
|
|
|
Perbedaan kecil:
|
|
- HTTP status code di header (best practice)
|
|
- Site API approve menggunakan JSON response (lebih konsisten)
|