mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-25 16:56:22 +02:00
2.3 KiB
2.3 KiB
Story 5.2: Tích hợp Stripe Checkout (Stripe Payment Integration)
Status: ready-for-dev
Story
As a Người dùng, I want bấm "Nâng cấp" và được chuyển tới trang thanh toán an toàn, so that tôi có thể điền thông tin thẻ tín dụng mà không sợ bị lộ dữ liệu trên máy chủ của SurfSense.
Acceptance Criteria
- Khi User bấm thanh toán, BE gọi API Stripe lấy
sessionIdcủa Stripe Checkout (Chế độ Subscription / Recurring Mode, không phải Chế độ Mua đứt OTP). - Hệ thống redirect User an toàn qua cổng Stripe được Hosted trực tiếp bởi Stripe Server.
Tasks / Subtasks
- Task 1: Nâng cấp
stripe_routes.py- Subtask 1.1: Bổ sung Endpoint POST
/api/v1/stripe/create-subscription-checkout. - Subtask 1.2: Phân tích
plan_idtừ Request body hoặc User, cấu hìnhmode='subscription'trong dict truyền cho thư viện Stripe (thay vì chế độpaymentcũ).
- Subtask 1.1: Bổ sung Endpoint POST
- Task 2: Liên kết Action Nút ở UI
- Subtask 2.1: Ở
PricingComponent, xử lýonClickbằng cách submit POST form request tới API mới, bắtcheckout_urlvà route trình duyệt tới URL đó bằng thẻ A hoặc JSwindow.location.href.
- Subtask 2.1: Ở
Dev Notes
Relevant Architecture Patterns & Constraints
- Codebase hiện có
surfsense_backend/app/routes/stripe_routes.pynhưng ĐANG GẮN code Payment Intent cho Token "Page Purchase" One-time 1 lần. DEV cần lưu ý CẤU HÌNH LẠI để route mới sinh này phục vụ riêng cho gói Subscription hàng tháng (Gửi theo CustomerID nếu User đã bind). - Security: Giá
stripe_price_idbắt buộc phải map và define ở Back-End environment variable (VdSTRIPE_PRO_PLAN_ID), tuyệt đối không chấp nhận parampricetừ Header gửi lên (Phòng tránh giả mạo giá tiền).
Project Structure Notes
- Module thay đổi:
surfsense_backend/app/routes/stripe_routes.pysurfsense_web/src/pages/pricing/page.tsx
References
- [Epic 5.2 - Subscriptions]
Dev Agent Record
Agent Model Used
Antigravity Claude 3.5 Sonnet Engine
File List
surfsense_backend/app/routes/stripe_routes.py