Conversation
기획 정책: 구매 후 7일 이내 + 프롬프트 미다운로드 조건 충족 시 사용자가 [환불하기] 클릭 → 즉시 Payple 결제 취소 + DB 정합화. ### Prisma 스키마 변경 - Status enum에 'Refunded' 추가 (Payment / Settlement 양쪽 적용) - Purchase.downloaded_at DateTime? 컬럼 추가 (첫 다운로드 시점 기록) - Refund 모델 신규 (purchase_id/payment_id @unique, user_id 인덱스, payple_card_trade_num 감사 추적) - 마이그레이션 파일: 20260523140000_add_refund_model_and_status ### 신규 API - GET /api/prompts/purchases/:purchaseId/refund-eligibility — 환불 가능 여부 + 사유 + 잔여 시간 - POST /api/prompts/purchases/:purchaseId/refund — 환불 실행 ### Payple 결제 취소 유틸 (utils/payple-refund.ts) - fetchRefundAuth: PCD_PAYCANCEL_FLAG=Y 파트너 인증, AuthKey Redis 15분 캐시 - requestPaypleRefund: PCD_REFUND_KEY 사용, PCD_PAY_OID/PAY_DATE/REFUND_TOTAL 전송 - 응답 PCD_PAY_CODE/PCD_PAY_CARDTRADENUM 저장 (감사용) - 인증 캐시에는 cstId/custKey 제외 — 매 호출 env 직접 로드 - 로그 redactor 적용 ### 다운로드 흐름 변경 (prompt.download.service.ts) - 유료 프롬프트 다운로드 시: - Refund 존재 시 403 Refunded (재다운로드 차단) - 첫 다운로드 시점에 Purchase.downloaded_at = NOW() set → 이후 환불 불가 - 무료 프롬프트는 영향 없음 ### 환불 실행 흐름 - 이중 검증 (TOCTOU): 서비스 진입 시 + Payple 호출 전 - Payple 성공 후 prisma.$transaction: - Refund row 생성 (initiator='USER', reason='7일 이내 미열람 자동 환불') - Payment.status='Refunded' - Settlement.status='Refunded' (존재 시) - Payple 실패 시 DB 변경 없음 - 트랜잭션 내부 멱등 검사 (Refund 중복 row 차단) ### 로그 redactor 확장 (payple.ts) - REDACTED_FIELDS에 PCD_REFUND_KEY / PCD_PAYER_ID / PCD_PAY_CARDTRADENUM 추가 ### 환경변수 - PAYPLE_REFUND_KEY: Payple 파트너 관리자에서 발급 - PAYPLE_REFUND_AUTH_PATH: 환불용 파트너 인증 endpoint (기본 /php/auth.php) 별도 이슈로 분리: - 관리자 수동 환불 (부분환불 등) - 환불 매출 자동 환수 회계 로직 - settlement-sync 잡의 CANCEL 매칭 보강 - 다운로드 이력 정규화 (PromptDownload 테이블)
[FEAT] 환불 - 7일 이내 미열람 자동 환불 흐름 및 Refund 모델 (#485)
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.
📌 기능 설명
📌 구현 내용
📌 구현 결과
📌 논의하고 싶은 점