chore: update project documentation, audit reports, and initialize IDE configuration files
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
Some checks failed
CI / Lint → Typecheck → Test → Build (22) (push) Failing after 29s
CI / E2E Tests (push) Has been skipped
CodeQL Analysis / CodeQL (javascript-typescript) (push) Failing after 2m42s
Deploy / Build Web Image (push) Failing after 27s
Deploy / Build AI Services Image (push) Failing after 29s
E2E Tests / Playwright E2E (push) Failing after 43s
Deploy / Build API Image (push) Failing after 1m31s
Security Scanning / Dependency Audit (pnpm) (push) Failing after 6s
Security Scanning / Trivy Scan — API Image (push) Failing after 5m35s
Security Scanning / Trivy Scan — AI Services Image (push) Failing after 3m45s
Deploy / Deploy to Staging (push) Has been skipped
Deploy / Smoke Test Staging (push) Has been skipped
Deploy / Deploy to Production (push) Has been skipped
Deploy / Smoke Test Production (push) Has been skipped
Deploy / Rollback Staging (push) Has been skipped
Deploy / Rollback Production (push) Has been skipped
Security Scanning / Trivy Scan — Web Image (push) Failing after 13m51s
Security Scanning / Trivy Filesystem Scan (push) Failing after 14m46s
Security Scanning / Security Gate (push) Has been cancelled
This commit is contained in:
@@ -1,103 +1,103 @@
|
||||
# GoodGo Pricing → Checkout Audit Summary
|
||||
# Tóm Tắt Kiểm Tra Định Giá → Thanh Toán GoodGo
|
||||
|
||||
## 🎯 Quick Overview
|
||||
## 🎯 Tổng Quan Nhanh
|
||||
|
||||
| Aspect | Status | Key Details |
|
||||
| Khía cạnh | Trạng thái | Chi tiết chính |
|
||||
|--------|--------|-------------|
|
||||
| **Pricing Page** | ✅ Complete | `/pricing` displays 4 tiers, monthly/yearly toggle |
|
||||
| **Plan API** | ✅ Complete | `GET /subscriptions/plans` with fallback data |
|
||||
| **Subscription Backend** | ✅ Complete | CQRS pattern, domain entities, repositories |
|
||||
| **Payment Gateway Integration** | ✅ Complete | VNPay, MoMo, ZaloPay ready to use |
|
||||
| **Payment API** | ✅ Complete | Create payment, get status, handle callbacks |
|
||||
| **Database Models** | ✅ Complete | Plan, Subscription, Payment, UsageRecord |
|
||||
| **Frontend Checkout Flow** | ❌ MISSING | No modal/page to initiate payment |
|
||||
| **Payment Return Handler** | ❌ MISSING | No page to handle gateway redirect |
|
||||
| **Subscription Auto-Creation** | ❌ MISSING | Manual process after payment |
|
||||
| **Trang Định Giá** | ✅ Hoàn chỉnh | `/pricing` hiển thị 4 gói, chuyển đổi tháng/năm |
|
||||
| **API Gói dịch vụ** | ✅ Hoàn chỉnh | `GET /subscriptions/plans` với dữ liệu dự phòng |
|
||||
| **Backend Đăng ký** | ✅ Hoàn chỉnh | Mẫu CQRS, thực thể miền, kho lưu trữ |
|
||||
| **Tích hợp Cổng Thanh toán** | ✅ Hoàn chỉnh | VNPay, MoMo, ZaloPay sẵn sàng sử dụng |
|
||||
| **API Thanh toán** | ✅ Hoàn chỉnh | Tạo thanh toán, lấy trạng thái, xử lý callback |
|
||||
| **Mô hình Cơ sở dữ liệu** | ✅ Hoàn chỉnh | Plan, Subscription, Payment, UsageRecord |
|
||||
| **Luồng Thanh toán Frontend** | ❌ THIẾU | Không có modal/trang để khởi tạo thanh toán |
|
||||
| **Trình xử lý Trả về Thanh toán** | ❌ THIẾU | Không có trang xử lý chuyển hướng từ cổng |
|
||||
| **Tự động Tạo Đăng ký** | ❌ THIẾU | Quy trình thủ công sau khi thanh toán |
|
||||
|
||||
---
|
||||
|
||||
## 🏗️ Architecture Overview
|
||||
## 🏗️ Tổng Quan Kiến Trúc
|
||||
|
||||
### Frontend Stack
|
||||
### Stack Frontend
|
||||
```
|
||||
Pricing Page (/pricing)
|
||||
↓ usePlans() hook
|
||||
Trang Định Giá (/pricing)
|
||||
↓ hook usePlans()
|
||||
↓ React Query
|
||||
API Client: subscriptionApi.getPlans()
|
||||
↓ GET /subscriptions/plans
|
||||
Backend (/subscriptions/plans endpoint)
|
||||
Backend (endpoint /subscriptions/plans)
|
||||
```
|
||||
|
||||
### Payment Flow (Currently Broken)
|
||||
### Luồng Thanh toán (Hiện bị Hỏng)
|
||||
```
|
||||
Pricing Page (Select Plan)
|
||||
✅ Displays plans, prices, features
|
||||
❌ CTAs link to /register instead of checkout
|
||||
Trang Định Giá (Chọn Gói)
|
||||
✅ Hiển thị gói, giá, tính năng
|
||||
❌ Nút CTA trỏ đến /register thay vì thanh toán
|
||||
|
||||
[MISSING] Checkout Modal/Page
|
||||
❌ Not implemented
|
||||
❌ No plan confirmation
|
||||
❌ No payment method selection
|
||||
[THIẾU] Modal/Trang Thanh toán
|
||||
❌ Chưa triển khai
|
||||
❌ Không có xác nhận gói
|
||||
❌ Không có lựa chọn phương thức thanh toán
|
||||
|
||||
[MISSING] Payment Creation
|
||||
❌ Should call POST /payments
|
||||
❌ Should redirect to paymentUrl
|
||||
[THIẾU] Tạo Thanh toán
|
||||
❌ Cần gọi POST /payments
|
||||
❌ Cần chuyển hướng đến paymentUrl
|
||||
|
||||
Payment Gateway (VNPay/MoMo/ZaloPay)
|
||||
✅ Backend has createPaymentUrl implementations
|
||||
✅ Signature verification ready
|
||||
❌ Frontend redirect not implemented
|
||||
Cổng Thanh toán (VNPay/MoMo/ZaloPay)
|
||||
✅ Backend có triển khai createPaymentUrl
|
||||
✅ Xác minh chữ ký đã sẵn sàng
|
||||
❌ Chưa triển khai chuyển hướng frontend
|
||||
|
||||
[MISSING] Return Handler
|
||||
❌ No page for gateway callback
|
||||
❌ No payment status polling
|
||||
❌ No subscription creation
|
||||
[THIẾU] Trình xử lý Trả về
|
||||
❌ Không có trang nhận callback từ cổng
|
||||
❌ Không có cơ chế poll trạng thái thanh toán
|
||||
❌ Không có tạo đăng ký
|
||||
|
||||
[MISSING] Subscription Creation
|
||||
❌ Should call POST /subscriptions
|
||||
❌ Should show success message
|
||||
[THIẾU] Tạo Đăng ký
|
||||
❌ Cần gọi POST /subscriptions
|
||||
❌ Cần hiển thị thông báo thành công
|
||||
|
||||
Dashboard/Home
|
||||
✅ Has payments page to view history
|
||||
❌ No subscription management UI
|
||||
Bảng điều khiển/Trang chủ
|
||||
✅ Có trang thanh toán để xem lịch sử
|
||||
❌ Không có giao diện quản lý đăng ký
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📁 Frontend File Structure
|
||||
## 📁 Cấu Trúc Tệp Frontend
|
||||
|
||||
```
|
||||
apps/web/
|
||||
├── app/[locale]/(public)/pricing/
|
||||
│ └── page.tsx ✅ Main pricing page
|
||||
│ └── page.tsx ✅ Trang định giá chính
|
||||
│
|
||||
├── lib/
|
||||
│ ├── subscription-api.ts ✅ API client & types (PlanDto, CreateSubscriptionResult, etc.)
|
||||
│ ├── payment-api.ts ✅ API client & types (CreatePaymentResult, PaymentStatusDto, etc.)
|
||||
│ ├── subscription-api.ts ✅ API client & types (PlanDto, CreateSubscriptionResult, v.v.)
|
||||
│ ├── payment-api.ts ✅ API client & types (CreatePaymentResult, PaymentStatusDto, v.v.)
|
||||
│ └── hooks/
|
||||
│ ├── use-subscription.ts ✅ usePlans(), useBillingHistory(), useQuota()
|
||||
│ └── use-payments.ts ✅ useTransactions(), usePaymentStatus()
|
||||
│
|
||||
├── app/[locale]/(dashboard)/dashboard/
|
||||
│ └── payments/page.tsx ✅ Transaction history viewer
|
||||
│ └── payments/page.tsx ✅ Trình xem lịch sử giao dịch
|
||||
│
|
||||
└── components/
|
||||
└── (needs new components for checkout)
|
||||
├── checkout-modal/ ❌ Missing
|
||||
├── payment-provider-select/ ❌ Missing
|
||||
└── subscription-status/ ❌ Missing
|
||||
└── (cần thêm component mới cho thanh toán)
|
||||
├── checkout-modal/ ❌ Thiếu
|
||||
├── payment-provider-select/ ❌ Thiếu
|
||||
└── subscription-status/ ❌ Thiếu
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔧 Backend File Structure
|
||||
## 🔧 Cấu Trúc Tệp Backend
|
||||
|
||||
```
|
||||
apps/api/src/modules/
|
||||
│
|
||||
├── subscriptions/
|
||||
│ ├── presentation/
|
||||
│ │ ├── controllers/subscriptions.controller.ts ✅ 8 endpoints
|
||||
│ │ ├── controllers/subscriptions.controller.ts ✅ 8 endpoint
|
||||
│ │ └── dto/
|
||||
│ │ ├── create-subscription.dto.ts ✅ { planTier, billingCycle }
|
||||
│ │ ├── upgrade-subscription.dto.ts ✅
|
||||
@@ -106,18 +106,18 @@ apps/api/src/modules/
|
||||
│ │
|
||||
│ ├── application/
|
||||
│ │ ├── commands/
|
||||
│ │ │ ├── create-subscription/ ✅ Creates subscription
|
||||
│ │ │ ├── create-subscription/ ✅ Tạo đăng ký
|
||||
│ │ │ ├── upgrade-subscription/ ✅
|
||||
│ │ │ ├── cancel-subscription/ ✅
|
||||
│ │ │ └── meter-usage/ ✅
|
||||
│ │ └── queries/
|
||||
│ │ ├── get-plan/ ✅ Returns PlanDto[]
|
||||
│ │ ├── get-plan/ ✅ Trả về PlanDto[]
|
||||
│ │ ├── check-quota/ ✅
|
||||
│ │ └── get-billing-history/ ✅
|
||||
│ │
|
||||
│ ├── domain/
|
||||
│ │ ├── entities/subscription.entity.ts ✅ CQRS aggregate
|
||||
│ │ ├── events/ ✅ 5 domain events
|
||||
│ │ ├── entities/subscription.entity.ts ✅ Aggregate CQRS
|
||||
│ │ ├── events/ ✅ 5 sự kiện miền
|
||||
│ │ └── repositories/subscription.repository.ts ✅ Interface
|
||||
│ │
|
||||
│ └── infrastructure/
|
||||
@@ -126,7 +126,7 @@ apps/api/src/modules/
|
||||
│
|
||||
└── payments/
|
||||
├── presentation/
|
||||
│ ├── controllers/payments.controller.ts ✅ 5 endpoints
|
||||
│ ├── controllers/payments.controller.ts ✅ 5 endpoint
|
||||
│ └── dto/
|
||||
│ ├── create-payment.dto.ts ✅ { provider, type, amountVND, description, returnUrl }
|
||||
│ ├── refund-payment.dto.ts ✅
|
||||
@@ -134,16 +134,16 @@ apps/api/src/modules/
|
||||
│
|
||||
├── application/
|
||||
│ ├── commands/
|
||||
│ │ ├── create-payment/ ✅ Main payment creation logic
|
||||
│ │ ├── handle-callback/ ✅ Webhook handler
|
||||
│ │ ├── create-payment/ ✅ Logic tạo thanh toán chính
|
||||
│ │ ├── handle-callback/ ✅ Trình xử lý webhook
|
||||
│ │ └── refund-payment/ ✅
|
||||
│ └── queries/
|
||||
│ ├── get-payment-status/ ✅ Poll status
|
||||
│ ├── get-payment-status/ ✅ Poll trạng thái
|
||||
│ └── list-transactions/ ✅
|
||||
│
|
||||
├── domain/
|
||||
│ ├── entities/payment.entity.ts ✅ CQRS aggregate
|
||||
│ ├── events/ ✅ 4 domain events
|
||||
│ ├── entities/payment.entity.ts ✅ Aggregate CQRS
|
||||
│ ├── events/ ✅ 4 sự kiện miền
|
||||
│ ├── value-objects/money.vo.ts ✅
|
||||
│ └── repositories/payment.repository.ts ✅ Interface
|
||||
│
|
||||
@@ -151,7 +151,7 @@ apps/api/src/modules/
|
||||
├── repositories/prisma-payment.repository.ts ✅
|
||||
└── services/
|
||||
├── payment-gateway.interface.ts ✅ IPaymentGateway
|
||||
├── payment-gateway.factory.ts ✅ Gets correct gateway
|
||||
├── payment-gateway.factory.ts ✅ Lấy cổng thanh toán phù hợp
|
||||
├── vnpay.service.ts ✅ createPaymentUrl() + verifyCallback()
|
||||
├── momo.service.ts ✅ createPaymentUrl() + verifyCallback()
|
||||
└── zalopay.service.ts ✅ createPaymentUrl() + verifyCallback()
|
||||
@@ -159,32 +159,32 @@ apps/api/src/modules/
|
||||
|
||||
---
|
||||
|
||||
## 🔌 API Endpoints Summary
|
||||
## 🔌 Tóm Tắt Endpoint API
|
||||
|
||||
### Subscription Endpoints
|
||||
### Endpoint Đăng ký
|
||||
```
|
||||
GET /subscriptions/plans → PlanDto[]
|
||||
GET /subscriptions/plans/:tier → PlanDto
|
||||
POST /subscriptions → CreateSubscriptionResult (requires auth)
|
||||
PUT /subscriptions/upgrade → UpgradeSubscriptionResult (requires auth)
|
||||
DELETE /subscriptions → CancelSubscriptionResult (requires auth)
|
||||
POST /subscriptions/usage → MeterUsageResult (requires auth)
|
||||
GET /subscriptions/quota/:metric → QuotaCheckResult (requires auth)
|
||||
GET /subscriptions/billing → BillingHistoryDto (requires auth)
|
||||
POST /subscriptions → CreateSubscriptionResult (yêu cầu xác thực)
|
||||
PUT /subscriptions/upgrade → UpgradeSubscriptionResult (yêu cầu xác thực)
|
||||
DELETE /subscriptions → CancelSubscriptionResult (yêu cầu xác thực)
|
||||
POST /subscriptions/usage → MeterUsageResult (yêu cầu xác thực)
|
||||
GET /subscriptions/quota/:metric → QuotaCheckResult (yêu cầu xác thực)
|
||||
GET /subscriptions/billing → BillingHistoryDto (yêu cầu xác thực)
|
||||
```
|
||||
|
||||
### Payment Endpoints
|
||||
### Endpoint Thanh toán
|
||||
```
|
||||
POST /payments → CreatePaymentResult (requires auth)
|
||||
POST /payments → CreatePaymentResult (yêu cầu xác thực)
|
||||
POST /payments/callback/:provider → HandleCallbackResult (webhook)
|
||||
GET /payments/:id → PaymentStatusDto (requires auth)
|
||||
GET /payments → TransactionListDto (requires auth)
|
||||
POST /payments/:id/refund → RefundPaymentResult (admin only)
|
||||
GET /payments/:id → PaymentStatusDto (yêu cầu xác thực)
|
||||
GET /payments → TransactionListDto (yêu cầu xác thực)
|
||||
POST /payments/:id/refund → RefundPaymentResult (chỉ quản trị viên)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 💰 Pricing Tiers
|
||||
## 💰 Các Gói Định Giá
|
||||
|
||||
```javascript
|
||||
const TIERS = [
|
||||
@@ -214,15 +214,15 @@ const TIERS = [
|
||||
tier: 'ENTERPRISE',
|
||||
monthlyVND: '4,990,000',
|
||||
yearlyVND: '49,900,000',
|
||||
maxListings: -1, // Unlimited
|
||||
maxSearches: -1, // Unlimited
|
||||
maxListings: -1, // Không giới hạn
|
||||
maxSearches: -1, // Không giới hạn
|
||||
},
|
||||
];
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 📊 Data Models (Prisma)
|
||||
## 📊 Mô Hình Dữ Liệu (Prisma)
|
||||
|
||||
### Plan
|
||||
```prisma
|
||||
@@ -264,18 +264,18 @@ amountVND: BigInt
|
||||
status: PaymentStatus (PENDING, PROCESSING, COMPLETED, FAILED, REFUNDED)
|
||||
providerTxId: String?
|
||||
callbackData: Json?
|
||||
idempotencyKey: String? ← Prevents duplicate payments
|
||||
idempotencyKey: String? ← Ngăn chặn thanh toán trùng lặp
|
||||
createdAt: DateTime
|
||||
updatedAt: DateTime
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🔑 Key Implementation Details
|
||||
## 🔑 Chi Tiết Triển Khai Quan Trọng
|
||||
|
||||
### Payment Creation Flow (Backend)
|
||||
### Luồng Tạo Thanh toán (Backend)
|
||||
```
|
||||
User clicks "Pay Now"
|
||||
Người dùng nhấn "Thanh toán ngay"
|
||||
↓
|
||||
Frontend: POST /payments {
|
||||
provider: 'VNPAY',
|
||||
@@ -283,204 +283,204 @@ Frontend: POST /payments {
|
||||
amountVND: 499000,
|
||||
description: 'Agent Pro - Monthly',
|
||||
returnUrl: 'https://goodgo.vn/payment-return',
|
||||
idempotencyKey: UUID ← Unique per payment attempt
|
||||
idempotencyKey: UUID ← Duy nhất cho mỗi lần thanh toán
|
||||
}
|
||||
↓
|
||||
Backend CreatePaymentHandler:
|
||||
1. Check idempotencyKey (prevent duplicates)
|
||||
2. Validate amount (1 to 100 billion VND)
|
||||
3. Get payment gateway (VNPay/MoMo/ZaloPay)
|
||||
4. Call gateway.createPaymentUrl()
|
||||
- Returns paymentUrl: "https://gateway.com/pay?params..."
|
||||
- Returns providerTxId: "VNP-12345..."
|
||||
5. Mark payment as PROCESSING in DB
|
||||
6. Publish PaymentCreatedEvent
|
||||
7. Return to client: { paymentId, paymentUrl, providerTxId }
|
||||
1. Kiểm tra idempotencyKey (ngăn trùng lặp)
|
||||
2. Xác thực số tiền (1 đến 100 tỷ VND)
|
||||
3. Lấy cổng thanh toán (VNPay/MoMo/ZaloPay)
|
||||
4. Gọi gateway.createPaymentUrl()
|
||||
- Trả về paymentUrl: "https://gateway.com/pay?params..."
|
||||
- Trả về providerTxId: "VNP-12345..."
|
||||
5. Đánh dấu thanh toán là PROCESSING trong DB
|
||||
6. Phát sự kiện PaymentCreatedEvent
|
||||
7. Trả về cho client: { paymentId, paymentUrl, providerTxId }
|
||||
↓
|
||||
Frontend:
|
||||
window.location = paymentUrl ← Redirect to gateway
|
||||
window.location = paymentUrl ← Chuyển hướng đến cổng
|
||||
↓
|
||||
User completes payment at gateway
|
||||
Người dùng hoàn tất thanh toán tại cổng
|
||||
↓
|
||||
Gateway redirects to returnUrl with callback params
|
||||
Cổng chuyển hướng đến returnUrl với tham số callback
|
||||
↓
|
||||
Backend webhook: POST /payments/callback/vnpay?params...
|
||||
1. Verify callback signature
|
||||
2. Check payment status
|
||||
3. Update payment status in DB
|
||||
4. Publish PaymentCompletedEvent
|
||||
1. Xác minh chữ ký callback
|
||||
2. Kiểm tra trạng thái thanh toán
|
||||
3. Cập nhật trạng thái thanh toán trong DB
|
||||
4. Phát sự kiện PaymentCompletedEvent
|
||||
↓
|
||||
PaymentCompletedEvent triggers:
|
||||
- Send email notification
|
||||
- Update user's plan association (eventually)
|
||||
PaymentCompletedEvent kích hoạt:
|
||||
- Gửi thông báo qua email
|
||||
- Cập nhật liên kết gói của người dùng (cuối cùng)
|
||||
↓
|
||||
Frontend callback handler (if implemented):
|
||||
1. Get paymentId from URL
|
||||
Trình xử lý callback frontend (nếu được triển khai):
|
||||
1. Lấy paymentId từ URL
|
||||
2. Poll GET /payments/{paymentId}
|
||||
3. When status = COMPLETED:
|
||||
3. Khi status = COMPLETED:
|
||||
- POST /subscriptions { planTier, billingCycle }
|
||||
- Show success message
|
||||
- Redirect to dashboard
|
||||
- Hiển thị thông báo thành công
|
||||
- Chuyển hướng đến bảng điều khiển
|
||||
```
|
||||
|
||||
### Payment Gateway Implementations
|
||||
### Triển Khai Cổng Thanh toán
|
||||
|
||||
#### VNPay
|
||||
```typescript
|
||||
// Signature: HMAC SHA-512
|
||||
// Request via: URL parameters
|
||||
// Response Code: vnp_ResponseCode = '00' means success
|
||||
// Transaction ID: vnp_TransactionNo
|
||||
// Chữ ký: HMAC SHA-512
|
||||
// Yêu cầu qua: Tham số URL
|
||||
// Mã phản hồi: vnp_ResponseCode = '00' nghĩa là thành công
|
||||
// Mã giao dịch: vnp_TransactionNo
|
||||
```
|
||||
|
||||
#### MoMo
|
||||
```typescript
|
||||
// Signature: HMAC SHA-256
|
||||
// Request via: JSON POST body
|
||||
// Response Code: resultCode = 0 means success
|
||||
// Transaction ID: transId
|
||||
// Chữ ký: HMAC SHA-256
|
||||
// Yêu cầu qua: Body JSON POST
|
||||
// Mã phản hồi: resultCode = 0 nghĩa là thành công
|
||||
// Mã giao dịch: transId
|
||||
```
|
||||
|
||||
#### ZaloPay
|
||||
```typescript
|
||||
// Signature: HMAC SHA-256 (similar to MoMo)
|
||||
// Request via: JSON POST body
|
||||
// Response Code: return_code = 1 means success
|
||||
// Transaction ID: zp_trans_id
|
||||
// Chữ ký: HMAC SHA-256 (tương tự MoMo)
|
||||
// Yêu cầu qua: Body JSON POST
|
||||
// Mã phản hồi: return_code = 1 nghĩa là thành công
|
||||
// Mã giao dịch: zp_trans_id
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🚨 Critical Gaps (What's Missing)
|
||||
## 🚨 Những Thiếu Sót Nghiêm Trọng (Những Gì Còn Thiếu)
|
||||
|
||||
### 1. Checkout Modal/Page ❌
|
||||
**What it should do:**
|
||||
- Display selected plan details
|
||||
- Show monthly vs yearly price
|
||||
- Allow payment method selection (VNPay, MoMo, ZaloPay)
|
||||
- Show terms & conditions
|
||||
- Handle payment creation and redirect
|
||||
### 1. Modal/Trang Thanh toán ❌
|
||||
**Chức năng cần có:**
|
||||
- Hiển thị chi tiết gói đã chọn
|
||||
- Hiện giá theo tháng và theo năm
|
||||
- Cho phép chọn phương thức thanh toán (VNPay, MoMo, ZaloPay)
|
||||
- Hiển thị điều khoản và điều kiện
|
||||
- Xử lý tạo thanh toán và chuyển hướng
|
||||
|
||||
**Current:** CTAs on pricing page link to `/register` instead of starting checkout
|
||||
**Hiện tại:** Nút CTA trên trang định giá trỏ đến `/register` thay vì bắt đầu thanh toán
|
||||
|
||||
### 2. Payment Return Handler ❌
|
||||
**What it should do:**
|
||||
- Receive redirect from payment gateway
|
||||
- Extract payment status from URL/callback
|
||||
- Poll payment status via GET /payments/:id
|
||||
- Create subscription when payment succeeds
|
||||
- Show success/error UI
|
||||
### 2. Trình xử lý Trả về Thanh toán ❌
|
||||
**Chức năng cần có:**
|
||||
- Nhận chuyển hướng từ cổng thanh toán
|
||||
- Trích xuất trạng thái thanh toán từ URL/callback
|
||||
- Poll trạng thái thanh toán qua GET /payments/:id
|
||||
- Tạo đăng ký khi thanh toán thành công
|
||||
- Hiển thị giao diện thành công/lỗi
|
||||
|
||||
**Current:** No page exists for this flow
|
||||
**Hiện tại:** Không có trang nào cho luồng này
|
||||
|
||||
### 3. Subscription Auto-Creation ❌
|
||||
**What it should do:**
|
||||
- After successful payment, call POST /subscriptions
|
||||
- Pass planTier and billingCycle
|
||||
- Update user's subscription status
|
||||
- Redirect to dashboard
|
||||
### 3. Tự động Tạo Đăng ký ❌
|
||||
**Chức năng cần có:**
|
||||
- Sau khi thanh toán thành công, gọi POST /subscriptions
|
||||
- Truyền planTier và billingCycle
|
||||
- Cập nhật trạng thái đăng ký của người dùng
|
||||
- Chuyển hướng đến bảng điều khiển
|
||||
|
||||
**Current:** Manual process, no UI
|
||||
**Hiện tại:** Quy trình thủ công, không có giao diện
|
||||
|
||||
### 4. Subscription Management UI ⚠️ Partial
|
||||
**What exists:**
|
||||
- Payments page shows transaction history
|
||||
### 4. Giao diện Quản lý Đăng ký ⚠️ Một phần
|
||||
**Những gì đã có:**
|
||||
- Trang thanh toán hiển thị lịch sử giao dịch
|
||||
|
||||
**What's missing:**
|
||||
- Subscription status/details page
|
||||
- Upgrade/downgrade plan UI
|
||||
- Cancel subscription UI
|
||||
- Usage/quota display
|
||||
**Những gì còn thiếu:**
|
||||
- Trang trạng thái/chi tiết đăng ký
|
||||
- Giao diện nâng cấp/hạ cấp gói
|
||||
- Giao diện hủy đăng ký
|
||||
- Hiển thị mức sử dụng/hạn mức
|
||||
|
||||
---
|
||||
|
||||
## 📋 Implementation Roadmap
|
||||
## 📋 Lộ Trình Triển Khai
|
||||
|
||||
### Phase 1: Basic Checkout (1-2 days)
|
||||
### Giai đoạn 1: Thanh toán Cơ bản (1-2 ngày)
|
||||
```
|
||||
✅ Pricing page exists
|
||||
❌ Add CheckoutModal component
|
||||
❌ Add payment provider selector
|
||||
❌ Create /payment-return page
|
||||
❌ Implement payment polling
|
||||
❌ Wire subscription creation
|
||||
✅ Trang định giá đã tồn tại
|
||||
❌ Thêm component CheckoutModal
|
||||
❌ Thêm bộ chọn nhà cung cấp thanh toán
|
||||
❌ Tạo trang /payment-return
|
||||
❌ Triển khai poll thanh toán
|
||||
❌ Kết nối tạo đăng ký
|
||||
```
|
||||
|
||||
### Phase 2: Full Integration (1-2 days)
|
||||
### Giai đoạn 2: Tích hợp Đầy đủ (1-2 ngày)
|
||||
```
|
||||
✅ All backend endpoints ready
|
||||
❌ Handle edge cases (timeout, user closes window, etc.)
|
||||
❌ Add error recovery flows
|
||||
❌ Add loading/success UI
|
||||
❌ Test with all 3 payment providers
|
||||
✅ Tất cả endpoint backend đã sẵn sàng
|
||||
❌ Xử lý các trường hợp ngoại lệ (hết thời gian, người dùng đóng cửa sổ, v.v.)
|
||||
❌ Thêm luồng phục hồi lỗi
|
||||
❌ Thêm giao diện đang tải/thành công
|
||||
❌ Kiểm tra với cả 3 nhà cung cấp thanh toán
|
||||
```
|
||||
|
||||
### Phase 3: Subscription Management (1-2 days)
|
||||
### Giai đoạn 3: Quản lý Đăng ký (1-2 ngày)
|
||||
```
|
||||
✅ Upgrade/downgrade API endpoints exist
|
||||
✅ Cancel subscription API exists
|
||||
❌ Build subscription detail page
|
||||
❌ Add upgrade/downgrade UI
|
||||
❌ Add cancel UI with confirmation
|
||||
❌ Add usage quota display
|
||||
✅ Endpoint API nâng cấp/hạ cấp đã tồn tại
|
||||
✅ API hủy đăng ký đã tồn tại
|
||||
❌ Xây dựng trang chi tiết đăng ký
|
||||
❌ Thêm giao diện nâng cấp/hạ cấp
|
||||
❌ Thêm giao diện hủy với xác nhận
|
||||
❌ Thêm hiển thị hạn mức sử dụng
|
||||
```
|
||||
|
||||
### Phase 4: Testing & Polish (1-2 days)
|
||||
### Giai đoạn 4: Kiểm tra & Hoàn thiện (1-2 ngày)
|
||||
```
|
||||
❌ E2E tests for all payment providers
|
||||
❌ Error handling & edge cases
|
||||
❌ Performance optimization
|
||||
❌ Analytics/tracking integration
|
||||
❌ Kiểm tra E2E cho tất cả nhà cung cấp thanh toán
|
||||
❌ Xử lý lỗi & các trường hợp ngoại lệ
|
||||
❌ Tối ưu hóa hiệu suất
|
||||
❌ Tích hợp phân tích/theo dõi
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 🎯 Next Steps
|
||||
## 🎯 Các Bước Tiếp Theo
|
||||
|
||||
1. **Understand the desired checkout UX** - Where/how should checkout start?
|
||||
- Modal from pricing page?
|
||||
- Separate checkout page?
|
||||
- Inline on pricing page?
|
||||
1. **Hiểu UX thanh toán mong muốn** - Thanh toán nên bắt đầu ở đâu/như thế nào?
|
||||
- Modal từ trang định giá?
|
||||
- Trang thanh toán riêng?
|
||||
- Trực tiếp trên trang định giá?
|
||||
|
||||
2. **Create CheckoutModal component** - Design it to match pricing page
|
||||
- Plan summary
|
||||
- Price breakdown
|
||||
- Payment provider selector
|
||||
- "Proceed to Payment" button
|
||||
2. **Tạo component CheckoutModal** - Thiết kế phù hợp với trang định giá
|
||||
- Tóm tắt gói
|
||||
- Phân tích giá
|
||||
- Bộ chọn nhà cung cấp thanh toán
|
||||
- Nút "Tiến hành Thanh toán"
|
||||
|
||||
3. **Implement payment creation mutation** - Hook into React Query
|
||||
- `useCreatePayment()` hook
|
||||
- Handle loading/error states
|
||||
- Redirect to paymentUrl
|
||||
3. **Triển khai mutation tạo thanh toán** - Kết nối với React Query
|
||||
- Hook `useCreatePayment()`
|
||||
- Xử lý trạng thái đang tải/lỗi
|
||||
- Chuyển hướng đến paymentUrl
|
||||
|
||||
4. **Build /payment-return page** - Handle gateway redirect
|
||||
- Parse URL params
|
||||
- Poll payment status
|
||||
- Create subscription on success
|
||||
4. **Xây dựng trang /payment-return** - Xử lý chuyển hướng từ cổng
|
||||
- Phân tích tham số URL
|
||||
- Poll trạng thái thanh toán
|
||||
- Tạo đăng ký khi thành công
|
||||
|
||||
5. **Test with all 3 providers** - Ensure all integrations work
|
||||
- Use sandbox/test credentials
|
||||
- Verify callbacks
|
||||
5. **Kiểm tra với cả 3 nhà cung cấp** - Đảm bảo tất cả tích hợp hoạt động
|
||||
- Sử dụng thông tin đăng nhập sandbox/kiểm tra
|
||||
- Xác minh callback
|
||||
|
||||
6. **Add subscription management UI** - Allow users to manage plans
|
||||
- View current subscription
|
||||
- Upgrade/downgrade
|
||||
- Cancel with confirmation
|
||||
6. **Thêm giao diện quản lý đăng ký** - Cho phép người dùng quản lý gói
|
||||
- Xem đăng ký hiện tại
|
||||
- Nâng cấp/hạ cấp
|
||||
- Hủy với xác nhận
|
||||
|
||||
---
|
||||
|
||||
## 📚 Reference
|
||||
## 📚 Tài Liệu Tham Khảo
|
||||
|
||||
Full audit document: `PRICING_CHECKOUT_AUDIT.md`
|
||||
Tài liệu kiểm tra đầy đủ: `PRICING_CHECKOUT_AUDIT.md`
|
||||
|
||||
Key files to review:
|
||||
Các tệp cần xem xét:
|
||||
- Frontend: `/apps/web/app/[locale]/(public)/pricing/page.tsx`
|
||||
- Backend payments: `/apps/api/src/modules/payments/`
|
||||
- Backend subscriptions: `/apps/api/src/modules/subscriptions/`
|
||||
- Prisma schema: `/prisma/schema.prisma` (lines 451-514)
|
||||
- Backend thanh toán: `/apps/api/src/modules/payments/`
|
||||
- Backend đăng ký: `/apps/api/src/modules/subscriptions/`
|
||||
- Prisma schema: `/prisma/schema.prisma` (dòng 451-514)
|
||||
|
||||
---
|
||||
|
||||
**Status:** Ready for checkout implementation
|
||||
**Estimated effort:** 4-6 days
|
||||
**Complexity:** Medium (all backend infrastructure is ready)
|
||||
**Trạng thái:** Sẵn sàng triển khai thanh toán
|
||||
**Ước tính công sức:** 4-6 ngày
|
||||
**Độ phức tạp:** Trung bình (toàn bộ hạ tầng backend đã sẵn sàng)
|
||||
|
||||
Reference in New Issue
Block a user