Skip to content

Commit 2cf3ba1

Browse files
committed
feat: 취소 기능 적용
1 parent ac381c3 commit 2cf3ba1

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/main/java/com/threestar/trainus/domain/payment/controller/PaymentController.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import org.springframework.http.HttpStatus;
44
import org.springframework.http.ResponseEntity;
5+
import org.springframework.web.bind.annotation.PathVariable;
56
import org.springframework.web.bind.annotation.PostMapping;
67
import org.springframework.web.bind.annotation.RequestBody;
78
import org.springframework.web.bind.annotation.RequestMapping;

src/main/java/com/threestar/trainus/domain/payment/service/PaymentService.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,11 @@ public void processCancel(TossPaymentResponseDto tossResponseDto) {
126126
TossPayment tossPayment = tossPaymentRepository.findByPaymentKey(tossResponseDto.getPaymentKey())
127127
.orElseThrow(() -> new BusinessException(ErrorCode.INVALID_PAYMENT));
128128

129-
tossPayment.changeStatus(LocalDateTime.parse(tossResponseDto.getRequestedAt()), null, PaymentStatus.CANCELED);
129+
DateTimeFormatter formatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
130+
LocalDateTime requestAt = OffsetDateTime.parse(tossResponseDto.getRequestedAt(), formatter).toLocalDateTime();
131+
132+
133+
tossPayment.changeStatus(requestAt, null, PaymentStatus.CANCELED);
130134

131135
tossPaymentRepository.save(tossPayment);
132136

0 commit comments

Comments
 (0)