Skip to content

Commit c25e345

Browse files
committed
feat: PaymentSucceededEvent에 결제 시간 파라미터 추가
1 parent 239334b commit c25e345

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

apps/commerce-api/src/main/java/com/loopers/application/payment/PaymentCallbackService.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212
import org.springframework.stereotype.Service;
1313
import org.springframework.transaction.annotation.Transactional;
1414

15+
import java.time.ZonedDateTime;
16+
1517
@Slf4j
1618
@Service
1719
@RequiredArgsConstructor
@@ -45,7 +47,7 @@ public void processCallback(PaymentCallbackDto callback) {
4547
log.info("결제 성공, 이벤트 발행: orderId={}, paymentId={}",
4648
order.getId(), payment.getId());
4749

48-
eventPublisher.publishEvent(PaymentSucceededEvent.of(payment, order.getCouponId()));
50+
eventPublisher.publishEvent(PaymentSucceededEvent.of(payment, order.getCouponId(), ZonedDateTime.now()));
4951

5052
} else {
5153
// 결제 실패 → 주문 실패 + 보상 트랜잭션 이벤트

apps/commerce-api/src/main/java/com/loopers/domain/payment/event/PaymentSucceededEvent.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public record PaymentSucceededEvent(
1414
PaymentMethod paymentMethod,
1515
ZonedDateTime paidAt
1616
) {
17-
public static PaymentSucceededEvent of(Payment payment, Long couponId) {
17+
public static PaymentSucceededEvent of(Payment payment, Long couponId, ZonedDateTime paidAt) {
1818
return new PaymentSucceededEvent(
1919
payment.getId(),
2020
payment.getOrderId(),
2121
payment.getUserId(),
2222
couponId,
2323
payment.getAmountValue(),
2424
payment.getPaymentMethod(),
25-
ZonedDateTime.now()
25+
paidAt != null ? paidAt : ZonedDateTime.now()
2626
);
2727
}
2828
}

0 commit comments

Comments
 (0)