Conversation
Payple 정산내역 조회 결과로 Settlement.status를 Pending → Succeed로 전이.
### 동기화 잡 (신규)
- src/settlements/jobs/settlement-sync.job.ts: KST 08:00 node-cron
- src/settlements/services/settlement-sync.service.ts: 동기화 코어 로직
- Redis 분산 락 (SET NX EX 600)으로 중복 실행 차단
- 어제 KST 정산일 1일 범위 호출
- 페이지네이션: PCD_LASTKEY를 Redis 24h TTL로 영속화 → 한도 도달 시 다음 cron이 이어받기
- 페이지당 1.1초 sleep (Payple 1초 1회 한도 준수)
- 잡당 최대 페이지 한도 (기본 100, env PAYPLE_SETTLEMENT_SYNC_MAX_PAGES_PER_RUN)
- APPROVAL만 처리, CANCEL은 skip + WARN (환불 흐름은 별도 이슈)
- 금액 일치 검증 (PCD_SETTLE_AMOUNT === Settlement.amount), 불일치 시 discrepancy 카운트 + ERROR 로그
- 멱등 가드: WHERE payment_id=? AND status='Pending' updateMany
- 결과 카운트 로그 (updated/skipped/missing/cancel_skipped/discrepancy/failed)
- src/index.ts에 startSettlementSyncJob 부트스트랩
### Auth 캐시 보안 보강 (payple-settlement.ts)
- AUTH_CACHE_TTL_SECONDS 25분 → 15분 단축
- 캐시 payload에서 cstId/custKey 제외 (매 호출 env 직접 로드, 캐시 노출 영역 축소)
- 응답 에러 로그에 redactPaypleLog 적용
### 로그 redactor 확장 (payple.ts)
- REDACTED_FIELDS에 정산 조회 필드 추가:
PCD_CUST_KEY / PCD_AUTH_KEY / PCD_CST_ID / PCD_PAYER_NAME /
PCD_PAY_BANKNUM / PCD_PAY_CARDNUM / PCD_LASTKEY / AuthKey
### 환경변수
- PAYPLE_SETTLEMENT_SYNC_ENABLED ('false'로 비활성화 가능)
- PAYPLE_SETTLEMENT_SYNC_MAX_PAGES_PER_RUN (기본 100)
별도 이슈로 분리:
- 환불 (CANCEL) 흐름 + Status.Refunded enum 확장 + Refund 모델
- 6개월 백필 스크립트
- Payple Webhook 도입
- PAYPLE_CUST_KEY 분리 / Secrets Manager 이전
23 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
결제 시
Settlement.status='Pending'으로 생성된 후 영구히 변경 안 되던 갭(#480에서 보고)을 채우기 위해, Payple 정산내역 조회 결과로Pending → Succeed전이하는 cron 동기화 잡 구현. 3개 에이전트 교차 검증 결과 반영.핵심 구현
node-cron— 기존prompt-stat-snapshot.job컨벤션 재사용SET NX EX 600)으로 컨테이너 중복 실행 차단PCD_HAS_MORE/PCD_LASTKEY처리, 한도 도달 시 다음 cron이 이어받음PCD_SETTLE_AMOUNT === Settlement.amount일 때만 Succeed. 불일치는discrepancy카운트 + ERROR 로그 (자동 업데이트 금지)where: { payment_id, status: 'Pending' }updateMany. 재실행 안전updated/skipped/missing/cancel_skipped/discrepancy/failed보안 보강 (이번 PR 동반)
payple-settlement.tsAuth 캐시 TTL 25분 → 15분 단축cstId/custKey제외 (매 호출 env 직접 로드 — 캐시 노출 영역 축소)payple.ts의REDACTED_FIELDS에 정산 조회 필드 추가:PCD_CUST_KEY,PCD_AUTH_KEY,PCD_CST_ID,PCD_PAYER_NAME,PCD_PAY_BANKNUM,PCD_PAY_CARDNUM,PCD_LASTKEY,AuthKey환경변수 (신규)
별도 이슈로 분리 (본 PR 범위 밖)
CANCEL) 흐름 +Status.Refundedenum 확장 +Refund모델PAYPLE_CUST_KEY분리 / AWS Secrets Manager 이전Test plan
pnpm build/pnpm tsc --noEmit통과PAYPLE_SETTLEMENT_AUTH_PATHsandbox 검증 포함)updated=0,skipped=Ncancel_skipped카운트 증가, Settlement 변경 없음discrepancy카운트 + ERROR 로그, 자동 업데이트 안 됨missing카운트 + WARNCloses #482