5.3 KiB
5.3 KiB
Cara Cek & Verifikasi API
🚀 Quick Start
1. Test dengan Script PHP (Paling Mudah)
cd timo.wipay.id_api
php test_api.php
Script ini akan test beberapa endpoint dasar dan menampilkan hasilnya.
2. Test dengan cURL (Manual)
# 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
- Buka Postman
- Buat request baru:
- Method:
POST - URL:
http://localhost:8000/timo/login - Headers:
Content-Type: application/json - Body (raw JSON):
{ "username": "testuser", "password": "testpass" }
- Method:
- Klik Send
- Lihat response
📊 Bandingkan dengan API Lama
Cara 1: Side-by-Side Comparison
- **Test API Lama:
http://timo.wipay.id/timo/login - Test API Baru:
http://localhost:8000/timo/login - Bandingkan response JSON-nya
Cara 2: Gunakan Diff Tool
# 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
# 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)
- ✅
POST /timo/login- Login user - ✅
POST /timo/cek_sl- Cek nomor SL - ✅
POST /timo/request_pembayaran- Request pembayaran - ✅
POST /timo/cek_pembayaran- Cek status pembayaran - ✅
POST /timo/confirm_pembayaran- Konfirmasi pembayaran
Prioritas Sedang
- ✅
POST /timo/daftar- Registrasi - ✅
POST /timo/update_akun- Update profil - ✅
POST /timo/cek_wipay- Cek saldo WIPAY - ✅
GET /timo/tagihan/{sl}- Data tagihan - ✅
POST /timo/history_bayar- History pembayaran
Prioritas Rendah
- Endpoint lainnya (lihat
RESPONSE_COMPARISON.md)
🛠️ Tools yang Bisa Digunakan
- cURL - Command line (sudah ada di Windows/Mac/Linux)
- Postman - GUI tool (download: https://www.postman.com/)
- Insomnia - Alternative Postman (https://insomnia.rest/)
- HTTPie - User-friendly CLI (https://httpie.io/)
- Browser DevTools - Untuk GET request
- jq - JSON formatter (https://stedolan.github.io/jq/)
📝 Contoh Test Lengkap
Test Login
# 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:
{
"status": 200,
"pesan": "Selamat Datang ...",
"user": {...},
"data_sl": [...]
}
Test Cek WIPAY
# 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:
{
"status": 404,
"wipay": 1,
"data": {...}
}
⚠️ Troubleshooting
Response berbeda?
- Cek file
RESPONSE_COMPARISON.mduntuk format yang benar - Cek kode di controller yang sesuai
- Cek query database
- Cek log error
Error 500?
- Cek error log
- Cek database connection
- Cek apakah semua dependency terinstall
Response kosong?
- Cek apakah data ada di database
- Cek query database
- Cek log error
📚 Dokumentasi Lengkap
TESTING_GUIDE.md- Panduan lengkap testingRESPONSE_COMPARISON.md- Perbandingan semua endpointFINAL_RESPONSE_CHECK.md- Summary finalREADME.md- Dokumentasi umum
💡 Tips
- Gunakan Data Real: Test dengan data yang sama di API lama dan baru
- Test Error Cases: Test dengan data invalid, token salah, dll
- Test Success Cases: Test dengan data valid
- Bandingkan Side-by-Side: Buka 2 terminal untuk bandingkan
- Gunakan JSON Formatter: Format JSON untuk mudah dibaca
- Test dengan Aplikasi Mobile: Jika memungkinkan, test langsung dengan aplikasi