HUONG DAN BAT API DOI TAC - CPANEL

CAC TRANG SAU KHI CAP NHAT
- Tai lieu API cong khai: https://dichvufast.id.vn/docs/
- Khu vuc doi tac: https://dichvufast.id.vn/api-partner/
- Quan ly doi tac (Admin): https://dichvufast.id.vn/admin/api-partners.html
- API Base URL: https://dichvufast.id.vn/api

BUOC 1 - SAO LUU
1. Sao luu toan bo public_html va database truoc khi cap nhat.
2. Giu nguyen config.php dang chay tren hosting. Goi cap nhat khong can va khong chua config.php that.

BUOC 2 - CAP NHAT MA NGUON
1. Upload cac file moi va ghi de api/index.php, admin/index.html, .htaccess theo goi cap nhat.
2. Upload thu muc docs/, api-partner/ va file admin/api-partners.html.
3. Giu lai config.php hien tai. Khong ghi de bang config.php.example.
4. Hosting can PHP 8.1+, PDO MySQL, cURL va mod_rewrite.

BUOC 3 - CAP NHAT DATABASE (BAT BUOC)
1. Mo cPanel > phpMyAdmin.
2. Chon dung database website.
3. Import migrations/0005_api_partner_wallet.mysql.sql mot lan duy nhat.
4. Migration them cot va bang moi, khong xoa du lieu don hang/CTV hien co.
5. Neu SQL bao loi duplicate column/index, dung lai va kiem tra schema truoc khi chay lai; khong xoa bang cu.

BUOC 4 - KIEM TRA SEPAY
Webhook van phai tro den:
https://dichvufast.id.vn/api/webhook/sepay
Header xac thuc:
Authorization: Apikey <SEPAY_API_KEY>

He thong nhan ma nap vi API dang API########. Chi cong so du khi giao dich tien vao, dung so tien va ma nap khop, webhook co API key dung va giao dich chua duoc xu ly.
Khong chuyen webhook sang api/sepay-webhook.php hoac sepay-webhook.php vi day la endpoint log cu, khong cong so du vi API.

BUOC 5 - TAO DOI TAC
1. Dang nhap Admin tong tai /admin/.
2. Chon nut Quan ly API doi tac, hoac mo /admin/api-partners.html.
3. Nhap ADMIN TOKEN (site_admin_token trong config.php), tao username va mat khau cho doi tac.
4. Sao chep API Key hien ra ngay luc tao va gui rieng cho doi tac. API Key khong the xem lai; neu mat thi dung Cap lai Key.
5. Admin co the cong/tru so du, khoa/mo khoa tai khoan.

BUOC 6 - DOI TAC SU DUNG
- Dang nhap: /api-partner/
- Nap tien: tao QR va chuyen khoan dung noi dung API########.
- Tai lieu tich hop: /docs/
- API Key gui trong header X-API-Key.
- Endpoint: GET /api/v1/me, GET /api/v1/plans, POST /api/v1/orders, GET /api/v1/orders/{order_code}.
- Moi lenh tao don can reference rieng de chong tao don trung khi retry.
- Neu kich hoat that bai, he thong tu hoan tien. Neu Admin kich hoat lai don API da loi, he thong se thu lai phi truoc khi thu lai va hoan lai neu tiep tuc loi.

GIA API
Mac dinh lay theo gia goi trong api/index.php: Trial 0d, Pro 19.000d, Premium 27.000d, Forever 69.000d.
Co the them cac khoa api_price_trial, api_price_pro, api_price_premium, api_price_forever vao config.php de tuy chinh. Gia tra ve tai GET /api/v1/plans la gia dang ap dung.

BAO MAT
- Khong chia se ADMIN TOKEN, API Key, database password, UPLOCKET_API_KEY hoac SEPAY_API_KEY.
- Chi goi API tu backend website doi tac; khong nhung API Key vao JavaScript frontend.
- Sao luu database truoc moi lan migration.
- Neu file config.php that tung duoc chia se cong khai, hay doi mat khau database va cac API token lien quan.
