File tree Expand file tree Collapse file tree
apps/commerce-api/src/main/java/com/loopers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -25,9 +25,9 @@ public void processCallback(PaymentCallbackDto callback) {
2525 log .info ("결제 콜백 처리 시작: transactionId={}, status={}" ,
2626 callback .transactionId (), callback .status ());
2727
28- Payment payment = paymentService .getPaymentByTransactionId (callback .transactionId ());
28+ Payment payment = paymentService .getPaymentByTransactionIdWithLock (callback .transactionId ());
2929
30- // 이미 처리된 결제는 스킵 (멱등성 보장)
30+ // 이미 처리된 결제는 스킵
3131 if (!payment .isPending ()) {
3232 log .warn ("이미 처리된 결제 (멱등성): transactionId={}, currentStatus={}" ,
3333 callback .transactionId (), payment .getStatus ());
Original file line number Diff line number Diff line change @@ -64,6 +64,15 @@ public Payment getPaymentByTransactionId(String transactionId) {
6464 "거래 ID에 해당하는 결제 정보를 찾을 수 없습니다." ));
6565 }
6666
67+ @ Transactional
68+ public Payment getPaymentByTransactionIdWithLock (String transactionId ) {
69+ return paymentRepository .findByTransactionIdWithLock (transactionId )
70+ .orElseThrow (() -> new CoreException (
71+ ErrorType .NOT_FOUND ,
72+ "결제 정보를 찾을 수 없습니다: " + transactionId
73+ ));
74+ }
75+
6776 @ Transactional (readOnly = true )
6877 public Optional <Payment > getPaymentByIdempotencyKey (String idempotencyKey ) {
6978 return paymentRepository .findByIdempotencyKey (idempotencyKey );
You can’t perform that action at this time.
0 commit comments