Skip to content

Commit

Permalink
Merge pull request #95 from marinesnow34/hotfix
Browse files Browse the repository at this point in the history
Hotfix
  • Loading branch information
marinesnow34 authored Apr 12, 2024
2 parents 8ec5f19 + 94f426e commit ee82371
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public class Receipt {
private Long taxExemptionAmount;

// @Column(columnDefinition = "json")
@Column
@Column(columnDefinition = "text")
private String cancels;

// @Column(columnDefinition = "json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@
public class Constant {
public static final Long EAT_IN = 1L;
public static final Long TAKE_OUT = 2L;
public static final Object TOSS_RESPONSE_FAIL_CANCELED = "ALREADY_CANCELED_PAYMENT";
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.readyvery.readyverydemo.src.order;

import static com.readyvery.readyverydemo.global.Constant.*;

import java.nio.charset.StandardCharsets;
import java.time.LocalDate;
import java.time.LocalDateTime;
Expand All @@ -12,8 +14,10 @@

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException;
import org.springframework.web.client.RestTemplate;

import net.minidev.json.JSONObject;
Expand All @@ -32,6 +36,7 @@
import com.readyvery.readyverydemo.global.exception.BusinessLogicException;
import com.readyvery.readyverydemo.global.exception.ExceptionCode;
import com.readyvery.readyverydemo.src.ceo.CeoServiceFacade;
import com.readyvery.readyverydemo.src.order.dto.FailDto;
import com.readyvery.readyverydemo.src.order.dto.OrderMapper;
import com.readyvery.readyverydemo.src.order.dto.OrderRegisterRes;
import com.readyvery.readyverydemo.src.order.dto.OrderStatusRes;
Expand Down Expand Up @@ -264,6 +269,22 @@ private TosspaymentDto requestTossPaymentCancel(String paymentKey, String reject
return restTemplate.postForObject(TossPaymentConfig.PAYMENT_URL + paymentKey + "/cancel",
new HttpEntity<>(params, headers),
TosspaymentDto.class);
} catch (HttpClientErrorException e) {
/*
* 취소 실패 시, 이미 취소된 거래라면 결제 정보 조회
* 취소된 정보 재적용
*/
if (e.getResponseBodyAs(FailDto.class).getCode()
.equals(TOSS_RESPONSE_FAIL_CANCELED)) {
return restTemplate.exchange(
TossPaymentConfig.PAYMENT_URL + paymentKey,
HttpMethod.GET,
new HttpEntity<>(headers),
TosspaymentDto.class)
.getBody();
}
throw new BusinessLogicException(ExceptionCode.TOSS_PAYMENT_SUCCESS_FAIL);

} catch (Exception e) {
log.error("e.getMessage() = " + e.getMessage());
throw new BusinessLogicException(ExceptionCode.TOSS_PAYMENT_SUCCESS_FAIL);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.readyvery.readyverydemo.src.order.dto;

import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

@Getter
@Builder
@AllArgsConstructor
@RequiredArgsConstructor
public class FailDto {
private String code;
private String message;
}

0 comments on commit ee82371

Please sign in to comment.