Initial commit: API Wipay dengan fix CORS untuk GET request
This commit is contained in:
215
CARA_CEK.md
Normal file
215
CARA_CEK.md
Normal file
@@ -0,0 +1,215 @@
|
||||
# Cara Cek & Verifikasi API
|
||||
|
||||
## 🚀 Quick Start
|
||||
|
||||
### 1. Test dengan Script PHP (Paling Mudah)
|
||||
|
||||
```bash
|
||||
cd timo.wipay.id_api
|
||||
php test_api.php
|
||||
```
|
||||
|
||||
Script ini akan test beberapa endpoint dasar dan menampilkan hasilnya.
|
||||
|
||||
### 2. Test dengan cURL (Manual)
|
||||
|
||||
```bash
|
||||
# Test health check
|
||||
curl http://localhost:8000/health
|
||||
|
||||
# Test login
|
||||
curl -X POST http://localhost:8000/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"testuser","password":"testpass"}'
|
||||
|
||||
# Test cek SL
|
||||
curl -X POST http://localhost:8000/timo/cek_sl \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"token":"1","no_sl":"123456"}'
|
||||
```
|
||||
|
||||
### 3. Test dengan Postman
|
||||
|
||||
1. Buka Postman
|
||||
2. Buat request baru:
|
||||
- Method: `POST`
|
||||
- URL: `http://localhost:8000/timo/login`
|
||||
- Headers: `Content-Type: application/json`
|
||||
- Body (raw JSON):
|
||||
```json
|
||||
{
|
||||
"username": "testuser",
|
||||
"password": "testpass"
|
||||
}
|
||||
```
|
||||
3. Klik Send
|
||||
4. Lihat response
|
||||
|
||||
## 📊 Bandingkan dengan API Lama
|
||||
|
||||
### Cara 1: Side-by-Side Comparison
|
||||
|
||||
1. **Test API Lama: `http://timo.wipay.id/timo/login`
|
||||
2. **Test API Baru**: `http://localhost:8000/timo/login`
|
||||
3. **Bandingkan** response JSON-nya
|
||||
|
||||
### Cara 2: Gunakan Diff Tool
|
||||
|
||||
```bash
|
||||
# Simpan response API lama
|
||||
curl -X POST http://timo.wipay.id/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"test","password":"test"}' > response_lama.json
|
||||
|
||||
# Simpan response API baru
|
||||
curl -X POST http://localhost:8000/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"test","password":"test"}' > response_baru.json
|
||||
|
||||
# Bandingkan (jika punya diff tool)
|
||||
diff response_lama.json response_baru.json
|
||||
```
|
||||
|
||||
### Cara 3: Format JSON untuk Mudah Dibaca
|
||||
|
||||
```bash
|
||||
# Install jq (untuk format JSON)
|
||||
# Windows: choco install jq
|
||||
# Mac: brew install jq
|
||||
# Linux: apt-get install jq
|
||||
|
||||
# Test dengan format JSON
|
||||
curl -X POST http://localhost:8000/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"test","password":"test"}' | jq
|
||||
```
|
||||
|
||||
## ✅ Checklist Verifikasi
|
||||
|
||||
### Format Response
|
||||
- [ ] Ada field `status` (200, 300, 404)
|
||||
- [ ] Ada field `pesan` (string)
|
||||
- [ ] Ada field `data` (jika ada di API lama)
|
||||
- [ ] Field khusus di root level (seperti `user`, `data_sl`, `wipay`)
|
||||
|
||||
### Data Response
|
||||
- [ ] Struktur data sama
|
||||
- [ ] Nama field sama
|
||||
- [ ] Tipe data sama
|
||||
- [ ] Nilai data sesuai
|
||||
|
||||
### Error Handling
|
||||
- [ ] Error message sama
|
||||
- [ ] Status code error sama
|
||||
- [ ] Format error response sama
|
||||
|
||||
## 🔍 Endpoint yang Perlu Dicek
|
||||
|
||||
### Prioritas Tinggi (Sering Dipakai)
|
||||
1. ✅ `POST /timo/login` - Login user
|
||||
2. ✅ `POST /timo/cek_sl` - Cek nomor SL
|
||||
3. ✅ `POST /timo/request_pembayaran` - Request pembayaran
|
||||
4. ✅ `POST /timo/cek_pembayaran` - Cek status pembayaran
|
||||
5. ✅ `POST /timo/confirm_pembayaran` - Konfirmasi pembayaran
|
||||
|
||||
### Prioritas Sedang
|
||||
6. ✅ `POST /timo/daftar` - Registrasi
|
||||
7. ✅ `POST /timo/update_akun` - Update profil
|
||||
8. ✅ `POST /timo/cek_wipay` - Cek saldo WIPAY
|
||||
9. ✅ `GET /timo/tagihan/{sl}` - Data tagihan
|
||||
10. ✅ `POST /timo/history_bayar` - History pembayaran
|
||||
|
||||
### Prioritas Rendah
|
||||
- Endpoint lainnya (lihat `RESPONSE_COMPARISON.md`)
|
||||
|
||||
## 🛠️ Tools yang Bisa Digunakan
|
||||
|
||||
1. **cURL** - Command line (sudah ada di Windows/Mac/Linux)
|
||||
2. **Postman** - GUI tool (download: https://www.postman.com/)
|
||||
3. **Insomnia** - Alternative Postman (https://insomnia.rest/)
|
||||
4. **HTTPie** - User-friendly CLI (https://httpie.io/)
|
||||
5. **Browser DevTools** - Untuk GET request
|
||||
6. **jq** - JSON formatter (https://stedolan.github.io/jq/)
|
||||
|
||||
## 📝 Contoh Test Lengkap
|
||||
|
||||
### Test Login
|
||||
|
||||
```bash
|
||||
# API Lama
|
||||
curl -X POST http://timo.wipay.id/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"testuser","password":"testpass"}' | jq
|
||||
|
||||
# API Baru
|
||||
curl -X POST http://localhost:8000/timo/login \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"username":"testuser","password":"testpass"}' | jq
|
||||
```
|
||||
|
||||
**Response yang Diharapkan:**
|
||||
```json
|
||||
{
|
||||
"status": 200,
|
||||
"pesan": "Selamat Datang ...",
|
||||
"user": {...},
|
||||
"data_sl": [...]
|
||||
}
|
||||
```
|
||||
|
||||
### Test Cek WIPAY
|
||||
|
||||
```bash
|
||||
# API Lama
|
||||
curl -X POST http://timo.wipay.id/timo/cek_wipay \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"token":"1"}' | jq
|
||||
|
||||
# API Baru
|
||||
curl -X POST http://localhost:8000/timo/cek_wipay \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"token":"1"}' | jq
|
||||
```
|
||||
|
||||
**Response yang Diharapkan:**
|
||||
```json
|
||||
{
|
||||
"status": 404,
|
||||
"wipay": 1,
|
||||
"data": {...}
|
||||
}
|
||||
```
|
||||
|
||||
## ⚠️ Troubleshooting
|
||||
|
||||
### Response berbeda?
|
||||
1. Cek file `RESPONSE_COMPARISON.md` untuk format yang benar
|
||||
2. Cek kode di controller yang sesuai
|
||||
3. Cek query database
|
||||
4. Cek log error
|
||||
|
||||
### Error 500?
|
||||
1. Cek error log
|
||||
2. Cek database connection
|
||||
3. Cek apakah semua dependency terinstall
|
||||
|
||||
### Response kosong?
|
||||
1. Cek apakah data ada di database
|
||||
2. Cek query database
|
||||
3. Cek log error
|
||||
|
||||
## 📚 Dokumentasi Lengkap
|
||||
|
||||
- `TESTING_GUIDE.md` - Panduan lengkap testing
|
||||
- `RESPONSE_COMPARISON.md` - Perbandingan semua endpoint
|
||||
- `FINAL_RESPONSE_CHECK.md` - Summary final
|
||||
- `README.md` - Dokumentasi umum
|
||||
|
||||
## 💡 Tips
|
||||
|
||||
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 untuk bandingkan
|
||||
5. **Gunakan JSON Formatter**: Format JSON untuk mudah dibaca
|
||||
6. **Test dengan Aplikasi Mobile**: Jika memungkinkan, test langsung dengan aplikasi
|
||||
Reference in New Issue
Block a user