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 이전
[FEAT] 정산 - 정산 완료 동기화 cron + Payple Auth 보안 보강 (#482)
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.
📌 기능 설명
📌 구현 내용
📌 구현 결과
📌 논의하고 싶은 점