Initial commit: API Wipay dengan fix CORS untuk GET request
This commit is contained in:
210
TESTING_GUIDE.md
Normal file
210
TESTING_GUIDE.md
Normal file
@@ -0,0 +1,210 @@
|
||||
# Panduan Testing & Verifikasi API
|
||||
|
||||
## Cara Testing API
|
||||
|
||||
### 1. Test dengan cURL (Command Line)
|
||||
|
||||
#### Test Health Check
|
||||
```bash
|
||||
curl http://localhost:8000/health
|
||||
```
|
||||
|
||||
#### Test Login
|
||||
```bash
|
||||
curl -X POST http://localhost:8000/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"testuser","password":"testpass","fcm_token":"test_token"}'
|
||||
```
|
||||
|
||||
#### Test Cek SL
|
||||
```bash
|
||||
curl -X POST http://localhost:8000/timo/cek_sl \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"token":"1","no_sl":"123456"}'
|
||||
```
|
||||
|
||||
#### Test Request Pembayaran
|
||||
```bash
|
||||
curl -X POST http://localhost:8000/timo/request_pembayaran \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"token":"1","no_sl":"123456","nama_bank":"BCA","no_rek":"1234567890"}'
|
||||
```
|
||||
|
||||
### 2. Test dengan Postman
|
||||
|
||||
1. Import collection (jika ada)
|
||||
2. Atau buat request manual:
|
||||
- Method: POST
|
||||
- URL: `http://localhost:8000/timo/login`
|
||||
- Headers: `Content-Type: application/json`
|
||||
- Body (raw JSON):
|
||||
```json
|
||||
{
|
||||
"username": "testuser",
|
||||
"password": "testpass"
|
||||
}
|
||||
```
|
||||
|
||||
### 3. Test dengan Browser (untuk GET request)
|
||||
|
||||
Buka browser dan akses:
|
||||
- `http://localhost:8000/health`
|
||||
- `http://localhost:8000/timo/tagihan/123456`
|
||||
|
||||
### 4. Bandingkan Response dengan API Lama
|
||||
|
||||
#### Cara Manual:
|
||||
1. Test endpoint di API lama: `http://timo.wipay.id/timo/login`
|
||||
2. Test endpoint di API baru: `http://localhost:8000/timo/login`
|
||||
3. Bandingkan response JSON-nya
|
||||
|
||||
#### Format Response yang Harus Sama:
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"pesan": "...",
|
||||
"data": {...}
|
||||
}
|
||||
```
|
||||
|
||||
## Checklist Verifikasi
|
||||
|
||||
### ✅ Format Response
|
||||
- [ ] Status code sama (200, 300, 404)
|
||||
- [ ] Field `status` ada dan sama
|
||||
- [ ] Field `pesan` ada dan sama
|
||||
- [ ] Field `data` ada (jika ada di API lama)
|
||||
- [ ] Field khusus (seperti `user`, `data_sl`, `wipay`) ada di root level
|
||||
|
||||
### ✅ Data Response
|
||||
- [ ] Struktur data sama
|
||||
- [ ] Nama field sama
|
||||
- [ ] Tipe data sama (string, number, array, object)
|
||||
- [ ] Urutan field (jika penting)
|
||||
|
||||
### ✅ Error Handling
|
||||
- [ ] Error message sama
|
||||
- [ ] Status code error sama
|
||||
- [ ] Format error response sama
|
||||
|
||||
## Endpoint yang Perlu Di-test
|
||||
|
||||
### Authentication
|
||||
- [ ] `POST /timo/daftar`
|
||||
- [ ] `POST /timo/login`
|
||||
- [ ] `POST /timo/login_token`
|
||||
- [ ] `POST /timo/update_akun`
|
||||
- [ ] `POST /timo/update_password`
|
||||
|
||||
### SL Management
|
||||
- [ ] `POST /timo/cek_sl`
|
||||
- [ ] `POST /timo/confirm_sl`
|
||||
- [ ] `POST /timo/hapus_sl`
|
||||
|
||||
### Tagihan
|
||||
- [ ] `GET /timo/history/{sl}/{periode}`
|
||||
- [ ] `GET /timo/tagihan/{sl}`
|
||||
|
||||
### Pembayaran
|
||||
- [ ] `POST /timo/request_pembayaran`
|
||||
- [ ] `POST /timo/cek_pembayaran`
|
||||
- [ ] `POST /timo/cek_transfer`
|
||||
- [ ] `POST /timo/batal_pembayaran`
|
||||
- [ ] `POST /timo/confirm_pembayaran`
|
||||
- [ ] `POST /timo/history_bayar`
|
||||
|
||||
### Laporan
|
||||
- [ ] `POST /timo/jenis_laporan`
|
||||
- [ ] `POST /timo/history_gangguan`
|
||||
|
||||
### WIPAY
|
||||
- [ ] `POST /timo/cek_wipay`
|
||||
|
||||
### Reset Password
|
||||
- [ ] `POST /timo/buat_kode`
|
||||
- [ ] `POST /timo/cek_kode`
|
||||
- [ ] `POST /timo/reset_kode`
|
||||
|
||||
### Upload
|
||||
- [ ] `POST /timo/upload_catat_meter`
|
||||
- [ ] `POST /timo/upload_pp`
|
||||
- [ ] `POST /timo/hapus_pp`
|
||||
- [ ] `POST /timo/upload_gangguan`
|
||||
- [ ] `POST /timo/upload_pasang_baru`
|
||||
- [ ] `POST /timo/upload_bukti_transfer`
|
||||
- [ ] `POST /timo/upload_baca_mandiri`
|
||||
|
||||
### Lainnya
|
||||
- [ ] `POST /timo/promo`
|
||||
- [ ] `POST /timo/riwayat_pasang`
|
||||
- [ ] `POST /timo/jadwal_catat_meter`
|
||||
- [ ] `POST /timo/request_order_baca_mandiri`
|
||||
|
||||
## Tips Testing
|
||||
|
||||
1. **Gunakan Data Real**: Test dengan data yang sama di API lama dan baru
|
||||
2. **Test Error Cases**: Test dengan data invalid, token salah, dll
|
||||
3. **Test Success Cases**: Test dengan data valid
|
||||
4. **Bandingkan Side-by-Side**: Buka 2 terminal/window untuk bandingkan response
|
||||
5. **Gunakan JSON Formatter**: Format JSON response untuk mudah dibaca
|
||||
6. **Test dengan Aplikasi Mobile**: Jika memungkinkan, test langsung dengan aplikasi mobile
|
||||
|
||||
## Tools yang Bisa Digunakan
|
||||
|
||||
1. **cURL** - Command line tool
|
||||
2. **Postman** - GUI tool untuk testing API
|
||||
3. **Insomnia** - Alternative untuk Postman
|
||||
4. **HTTPie** - User-friendly command line HTTP client
|
||||
5. **Browser DevTools** - Untuk test GET request
|
||||
6. **jq** - Untuk format JSON di terminal: `curl ... | jq`
|
||||
|
||||
## Contoh Test Script (Bash)
|
||||
|
||||
```bash
|
||||
#!/bin/bash
|
||||
|
||||
BASE_URL="http://localhost:8000"
|
||||
TOKEN="your_token_here"
|
||||
|
||||
echo "Testing Health Check..."
|
||||
curl -s "$BASE_URL/health"
|
||||
echo -e "\n\n"
|
||||
|
||||
echo "Testing Login..."
|
||||
curl -s -X POST "$BASE_URL/timo/login" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"test","password":"test"}' | jq
|
||||
echo -e "\n\n"
|
||||
|
||||
echo "Testing Cek WIPAY..."
|
||||
curl -s -X POST "$BASE_URL/timo/cek_wipay" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d "{\"token\":\"$TOKEN\"}" | jq
|
||||
echo -e "\n\n"
|
||||
```
|
||||
|
||||
## Catatan Penting
|
||||
|
||||
1. **Database**: Pastikan database yang digunakan sama dengan API lama
|
||||
2. **Environment**: Pastikan environment variables sudah benar (.env)
|
||||
3. **File Upload**: Test upload dengan file real (base64 encoded)
|
||||
4. **External API**: Pastikan koneksi ke external API (timo.tirtaintan.co.id) berfungsi
|
||||
5. **CORS**: Pastikan CORS sudah di-enable jika test dari browser
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
### Response berbeda dengan API lama?
|
||||
1. Cek format response di `RESPONSE_COMPARISON.md`
|
||||
2. Cek kode di controller yang sesuai
|
||||
3. Cek query database apakah sama
|
||||
4. Cek logic bisnis apakah sama
|
||||
|
||||
### Error 500?
|
||||
1. Cek error log di `logs/` atau PHP error log
|
||||
2. Cek database connection
|
||||
3. Cek apakah semua dependency sudah terinstall
|
||||
|
||||
### Response kosong?
|
||||
1. Cek apakah data ada di database
|
||||
2. Cek query database
|
||||
3. Cek apakah ada error di log
|
||||
Reference in New Issue
Block a user