[JDDEV-74] [JDDEV-73] 크레딧 결제 로직 구현#66
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughThis PR integrates the Toss Payments SDK to enable dynamic credit purchases. It adds a new credit API module, converts the credit page to fetch and render plans dynamically, wires the modal to handle payment confirmation through Toss, refactors credit balance fetching into component state, and introduces a new transaction history component. ChangesCredit Purchase and Transaction System
Sequence DiagramsequenceDiagram
participant User
participant CreditPage
participant API as credit API
participant CreditCard
participant ModalPurchase
participant TossSDK as Toss Payments SDK
User->>CreditPage: visit page
CreditPage->>API: fetchCreditPlans()
API-->>CreditPage: plans[]
CreditPage->>CreditPage: render CreditCard per plan
User->>CreditCard: click purchase button
CreditCard->>ModalPurchase: open modal with planCode
User->>ModalPurchase: click confirm
ModalPurchase->>API: preparePurchase(planCode)
API-->>ModalPurchase: PreparePaymentResult{orderId, clientKey, amount...}
ModalPurchase->>TossSDK: loadTossPayments(clientKey)
ModalPurchase->>TossSDK: createPayment() + requestPayment(CARD)
TossSDK-->>ModalPurchase: payment result
alt payment success
ModalPurchase->>API: confirmPurchase(paymentKey, orderId, amount)
API-->>ModalPurchase: void (success)
ModalPurchase->>ModalPurchase: close modal
else payment error
ModalPurchase->>ModalPurchase: clear loading, show error
end
🎯 3 (Moderate) | ⏱️ ~20 minutes
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
🔗 관련 이슈
📝 개요
⌨️ 작업 상세 내용
크레딧 API 연동
GET /api/payments/credits/me)GET /api/payments/credits/me/transactions)GET /api/payments/plans)토스 결제 흐름 구현
POST /api/payments/prepare) → 토스 결제창 오픈/credit?paymentKey=...리디렉션 수신POST /api/payments/confirm) 자동 처리UI 연동
변경 파일
src/lib/api/credit.ts— API 함수 정의src/components/common/lnb/Lnb.tsx— 잔액 표시 / 애니메이션src/components/common/modal/ModalPurchase.tsx— 토스 결제 연동src/components/common/cards/CreditCard.tsx— planCode 연결src/app/credit/page.tsx— 플랜 렌더링 / confirm 처리src/components/common/credit/Useage.tsx— 거래 내역 연동📸 스크린샷 (UI 변경 시)
🔍 리뷰 요구사항 (Reviewers)
Summary by CodeRabbit