Skip to content

[Feat/#107] 사장님 승격 및 결제 완료 처리 API 연동#109

Merged
skyblue1232 merged 2 commits into
developfrom
feat/#107/owner-upgrade
Apr 30, 2026
Merged

[Feat/#107] 사장님 승격 및 결제 완료 처리 API 연동#109
skyblue1232 merged 2 commits into
developfrom
feat/#107/owner-upgrade

Conversation

@skyblue1232

@skyblue1232 skyblue1232 commented Apr 30, 2026

Copy link
Copy Markdown
Contributor

✅ 작업 내용

📝 Description

  • owner 앱 점장 승격 API 연동
  • customer 앱 결제 완료 후 정산 처리 API 연동
  • Swagger 기준 request/response 타입 정리

작업한 내용을 체크해주세요.

  • PATCH /owners/upgrade 연동
  • POST /admin/settlements/{storeId}/complete 연동
  • React Query mutation hook 추가
  • 카카오페이 승인 후 후처리 로직 연결

🚀 설계 의도 및 개선점

  • domain module 기반으로 owner/customer API 책임 분리
  • 결제 승인 이후 정산 API를 순차 호출하도록 플로우 개선
  • 정산 API 실패 여부와 관계없이 결제 UX가 유지되도록 처리

📎 기타 참고사항

  • Swagger 기준 타입 수정 및 API module export 반영
  • mutation 성공 후 cache invalidate 적용

Summary by CodeRabbit

릴리스 노트

신기능

  • 결제 승인 후 정산 완료 처리가 자동으로 실행되어 결제 프로세스가 개선되었습니다
  • 사업자 가입 단계에서 기존 사업자번호 검증 프로세스가 스토어 매니저 업그레이드 프로세스로 변경되었습니다

제거된 기능

  • 정산 미리보기 기능이 제거되었습니다

@skyblue1232 skyblue1232 self-assigned this Apr 30, 2026
@skyblue1232 skyblue1232 added feat 기능 구현 및 생성 chore 자잘한 수정 api 서버 - 클라이언트 통신 labels Apr 30, 2026
@vercel

vercel Bot commented Apr 30, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
compasser-customer Ready Ready Preview, Comment Apr 30, 2026 6:49pm
compasser-owner Ready Ready Preview, Comment Apr 30, 2026 6:49pm

@coderabbitai

coderabbitai Bot commented Apr 30, 2026

Copy link
Copy Markdown
📝 Walkthrough

Walkthrough

결제 성공 흐름에 Kakao Pay 승인 후 admin settlement 완료 뮤테이션을 추가하고, owner 가입 흐름을 비즈니스 라이센스 검증에서 스토어 매니저 업그레이드로 변경하며, settlement-preview 기능을 제거하는 API 구조 개편입니다.

Changes

Cohort / File(s) Summary
Admin Settlement Domain 추가
packages/api/src/models/admin-settlement.ts, packages/api/src/domains/admin-settlement.ts, packages/api/src/index.ts
AdminSettlement 완료 요청/응답 DTO와 캐시 키 전략, POST /admin/settlements/{storeId}/complete 엔드포인트 호출 및 React Query 캐시 업데이트 로직을 포함한 새 도메인 모듈 생성 및 재내보내기.
고객 결제 성공 플로우 수정
apps/customer/src/app/payment/success/page.tsx
Kakao Pay 승인 후 completeAdminSettlementMutation 호출 추가, 모달 열림과 세션 정리를 settlement 뮤테이션이 onSettled에 도달할 때까지 지연, 초기화 이펙트를 useRef 불린으로 보호.
고객 API 모듈 확장
apps/customer/src/shared/api/api.ts, apps/customer/src/shared/queries/mutation/admin-settlement/useCompleteAdminSettlementMutation.ts
adminSettlementModule 생성 및 내보내기, useCompleteAdminSettlementMutation 훅 추가로 admin settlement 완료 뮤테이션 사용 가능하게 구성.
Owner 가입 플로우 및 API 모델 변경
apps/owner/src/app/signup/business/page.tsx, packages/api/src/models/owner.ts
비즈니스 라이센스 검증에서 스토어 매니저 업그레이드로 변경, BusinessLicenseVerifyReqDTO를 더 많은 필드(ownerName, startDate, businessName)를 요구하도록 업데이트, settlement-preview DTO 제거.
Owner 쿼리 및 도메인 수정
apps/owner/src/shared/queries/mutation/auth/useUpgradeToStoreManagerMutation.ts, apps/owner/src/shared/queries/mutation/auth/useVerifyBusinessMutation.ts, packages/api/src/domains/owner.ts
useUpgradeToStoreManagerMutation 훅 추가, useVerifyBusinessMutation 스프레드 문법 조정, owner 도메인에서 settlement-preview 캐시 키 및 쿼리 옵션 제거.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client<br/>(Payment Success Page)
    participant API as Compasser API
    participant QueryCache as React Query<br/>Cache
    participant DB as Backend<br/>Database

    Client->>API: POST /kakao/complete<br/>(reservationId)
    API->>DB: 결제 승인 처리
    DB-->>API: 승인 성공
    API-->>Client: 성공 응답

    Note over Client: 보류 중 결제에서<br/>storeId 추출

    Client->>API: POST /admin/settlements/{storeId}/complete<br/>(reservationIds)
    API->>DB: Settlement 완료 기록
    DB-->>API: Settlement 완료 데이터
    API-->>Client: 응답 반환

    Client->>QueryCache: 캐시 업데이트<br/>(완료 결과 저장)
    QueryCache->>QueryCache: Admin Settlement 데이터<br/>무효화 및 재검증

    Note over Client: 모달 열기 & 세션 정리
    Client->>Client: UI 업데이트 완료
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Possibly related PRs

  • [Feat/#88] 사장님 메인화면 API 연동 #96: 두 PR 모두 owner settlement 관련 API 표면(packages/api/src/domains/owner.ts 및 owner 모델)을 수정하는데, 검색된 PR은 settlement-preview 지원을 추가하고 메인 PR은 제거하면서 admin-settlement 도메인을 도입하므로 동일한 코드 영역을 직접 수정합니다.

  • [Feat/#98] 사용자 랜덤박스 구매 API 연동 #102: 메인 PR은 검색된 PR에서 도입된 결제 성공 플로우를 확장하여 completeAdminSettlement 뮤테이션을 추가하고 모달 열림/세션 정리를 settlement 뮤테이션이 settles될 때까지 지연시키므로, 동일한 결제 성공 컴포넌트 및 API 내보내기와 직접 관련됩니다.

Poem

🐰 Settlement의 새로운 길

결제 성공 후 Admin이 나타나
정산을 완료하는 마법의 여행
Owner도 매니저로 업그레이드되고
API는 더욱 명확하게 정돈되었네
캐시는 춤을 추며 데이터를 갱신해! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed PR 제목이 변경 사항의 주요 내용을 명확하게 요약하고 있습니다. 사장님 승격 및 결제 완료 처리 API 연동이라는 핵심 변경 사항을 정확히 반영합니다.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/#107/owner-upgrade

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
Review rate limit: 0/1 reviews remaining, refill in 60 minutes.

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/owner/src/app/signup/business/page.tsx (1)

55-81: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

업그레이드 API와 검증 게이트가 불일치합니다.

Line 56-61에서 사업자번호 검증 실패 시 진행을 막고 있지만, Line 68에서 호출하는 upgradeMutationundefined로 호출되어 해당 값을 전혀 사용하지 않습니다. 현재 상태면 “서버에 필요 없는 입력값” 때문에 승격이 차단될 수 있습니다.

/owners/upgrade 플로우를 유지할 거라면 이 검증 게이트를 제거(또는 안내 문구/입력 UI 자체 정리)하고, 사업자 검증이 필수라면 검증 API 호출 플로우로 되돌려야 합니다.

수정 예시 (업그레이드 API 기준)
   const handleNext = () => {
-    const message = validate();
-
-    if (message) {
-      setError(message);
-      return;
-    }
-
     if (!email) {
       router.replace("/signup");
       return;
     }

     upgradeMutation.mutate(undefined, {
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/owner/src/app/signup/business/page.tsx` around lines 55 - 81, The
validation gate in handleNext (validate() and the email check) is inconsistent
with calling upgradeMutation.mutate(undefined); fix by making the validation
result feed the upgrade flow: after validate() succeeds, call
upgradeMutation.mutate with the required payload (e.g., businessNumber and/or
email) instead of undefined and/or call the business-validation API first and
only call upgradeMutation on its success; update handleNext (and related UI) so
validate(), email, and upgradeMutation.mutate(payload) all use the same required
fields and remove any dead/contradictory checks if you choose to move validation
server-side.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@apps/customer/src/app/payment/success/page.tsx`:
- Around line 57-63: Wrap the JSON.parse of savedPayment in a try-catch and
handle parse failures (e.g., log the error and abort/redirect), and before
calling completeAdminSettlementMutation.mutate ensure parsedPayment is an object
with the expected shape (check parsedPayment?.store and
parsedPayment.store?.storeId) and that reservationId is defined; if validations
fail, bail out with a safe fallback or error path instead of accessing nested
fields directly in completeAdminSettlementMutation.mutate to prevent runtime
crashes.

---

Outside diff comments:
In `@apps/owner/src/app/signup/business/page.tsx`:
- Around line 55-81: The validation gate in handleNext (validate() and the email
check) is inconsistent with calling upgradeMutation.mutate(undefined); fix by
making the validation result feed the upgrade flow: after validate() succeeds,
call upgradeMutation.mutate with the required payload (e.g., businessNumber
and/or email) instead of undefined and/or call the business-validation API first
and only call upgradeMutation on its success; update handleNext (and related UI)
so validate(), email, and upgradeMutation.mutate(payload) all use the same
required fields and remove any dead/contradictory checks if you choose to move
validation server-side.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 41a7172d-d9a2-4b83-a5af-409b28c766f4

📥 Commits

Reviewing files that changed from the base of the PR and between c4a16b4 and 7c6a676.

📒 Files selected for processing (11)
  • apps/customer/src/app/payment/success/page.tsx
  • apps/customer/src/shared/api/api.ts
  • apps/customer/src/shared/queries/mutation/admin-settlement/useCompleteAdminSettlementMutation.ts
  • apps/owner/src/app/signup/business/page.tsx
  • apps/owner/src/shared/queries/mutation/auth/useUpgradeToStoreManagerMutation.ts
  • apps/owner/src/shared/queries/mutation/auth/useVerifyBusinessMutation.ts
  • packages/api/src/domains/admin-settlement.ts
  • packages/api/src/domains/owner.ts
  • packages/api/src/index.ts
  • packages/api/src/models/admin-settlement.ts
  • packages/api/src/models/owner.ts
💤 Files with no reviewable changes (1)
  • packages/api/src/domains/owner.ts

Comment on lines +57 to +63
completeAdminSettlementMutation.mutate(
{
storeId: parsedPayment.store.storeId,
body: {
reservationIds: [reservationId],
},
},

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major | ⚡ Quick win

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# 결제 성공 페이지에서 역직렬화/필드 접근 무가드 구간 확인
rg -n -C3 'JSON.parse\(savedPayment\)|parsedPayment\.store\.storeId|reservationIds:\s*\[' apps/customer/src/app/payment/success/page.tsx

Repository: CUK-Compasser/FE

Length of output: 519


🏁 Script executed:

cat -n apps/customer/src/app/payment/success/page.tsx

Repository: CUK-Compasser/FE

Length of output: 3646


🏁 Script executed:

# reservationId 변수 출처 확인
rg -n "reservationId" apps/customer/src/app/payment/success/page.tsx | head -20

Repository: CUK-Compasser/FE

Length of output: 357


🏁 Script executed:

# savedPayment 변수 출처 및 초기값 확인
rg -n "savedPayment|sessionStorage" apps/customer/src/app/payment/success/page.tsx | head -20

Repository: CUK-Compasser/FE

Length of output: 331


세션 데이터 파싱과 필드 접근이 무가드라 런타임 크래시 위험이 있습니다.

Line 46에서 JSON.parse(savedPayment)가 try-catch 없이 호출되고 있어, sessionStorage 데이터가 손상된 경우 SyntaxError로 결제 성공 플로우가 깨질 수 있습니다. 또한 Line 59의 parsedPayment.store.storeId 중첩 접근도 파싱된 객체의 구조를 검증하지 않아 TypeScript 타입 정보가 런타임에 제거되면 런타임 에러가 발생할 수 있습니다.

🔧 제안 수정안
-    const parsedPayment = JSON.parse(savedPayment) as PendingPayment;
+    let parsedPayment: PendingPayment;
+    try {
+      parsedPayment = JSON.parse(savedPayment) as PendingPayment;
+    } catch {
+      sessionStorage.removeItem("pendingPayment");
+      return;
+    }
+
+    if (!parsedPayment?.store?.storeId || !parsedPayment?.reservationId) {
+      sessionStorage.removeItem("pendingPayment");
+      return;
+    }

     setPendingPayment(parsedPayment);

     approveKakaoPayMutation.mutate(
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@apps/customer/src/app/payment/success/page.tsx` around lines 57 - 63, Wrap
the JSON.parse of savedPayment in a try-catch and handle parse failures (e.g.,
log the error and abort/redirect), and before calling
completeAdminSettlementMutation.mutate ensure parsedPayment is an object with
the expected shape (check parsedPayment?.store and parsedPayment.store?.storeId)
and that reservationId is defined; if validations fail, bail out with a safe
fallback or error path instead of accessing nested fields directly in
completeAdminSettlementMutation.mutate to prevent runtime crashes.

@skyblue1232 skyblue1232 merged commit 67d95d5 into develop Apr 30, 2026
5 checks passed
@skyblue1232 skyblue1232 linked an issue Apr 30, 2026 that may be closed by this pull request
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api 서버 - 클라이언트 통신 chore 자잘한 수정 feat 기능 구현 및 생성

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat] 사장님 승격 및 정산 완료 API 연동

1 participant