-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #110 from daadaadaah/feat/add-approveOrder
토스 페이먼츠 결제 승인 로직 전의 주문 승인 로직 추가
- Loading branch information
Showing
12 changed files
with
349 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
11 changes: 11 additions & 0 deletions
11
src/main/java/com/hcommerce/heecommerce/order/InvalidPaymentAmountException.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import org.springframework.http.HttpStatus; | ||
import org.springframework.web.bind.annotation.ResponseStatus; | ||
|
||
@ResponseStatus(HttpStatus.BAD_REQUEST) | ||
public class InvalidPaymentAmountException extends RuntimeException { | ||
public InvalidPaymentAmountException() { | ||
super("결제 금액이 유효하지 않습니다."); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/main/java/com/hcommerce/heecommerce/order/OrderApproveForm.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import jakarta.validation.constraints.NotNull; | ||
import java.beans.ConstructorProperties; | ||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class OrderApproveForm { | ||
|
||
@NotNull | ||
private final String paymentKey; // 토스 키 | ||
|
||
@NotNull | ||
private final String orderId; // 토스 주문 식별자 | ||
|
||
@NotNull | ||
private final int amount; // 총 결제 금액 | ||
|
||
@Builder | ||
@ConstructorProperties({ | ||
"paymentKey", | ||
"orderId", | ||
"amount" | ||
}) | ||
public OrderApproveForm(String paymentKey, String orderId, int amount) { | ||
this.paymentKey = paymentKey; | ||
this.orderId = orderId; | ||
this.amount = amount; | ||
} | ||
} |
This file contains 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
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hcommerce/heecommerce/order/OrderEntityForOrderApproveValidation.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import lombok.Builder; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
public class OrderEntityForOrderApproveValidation { | ||
|
||
private final byte[] dealProductUuid; | ||
private final int orderQuantity; | ||
private final int totalPaymentAmount; | ||
private final OutOfStockHandlingOption outOfStockHandlingOption; | ||
|
||
@Builder | ||
public OrderEntityForOrderApproveValidation( | ||
byte[] dealProductUuid, | ||
int orderQuantity, | ||
int totalPaymentAmount, | ||
OutOfStockHandlingOption outOfStockHandlingOption | ||
) { | ||
this.dealProductUuid = dealProductUuid; | ||
this.orderQuantity = orderQuantity; | ||
this.totalPaymentAmount = totalPaymentAmount; | ||
this.outOfStockHandlingOption = outOfStockHandlingOption; | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/com/hcommerce/heecommerce/order/OrderQueryMapper.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import org.apache.ibatis.annotations.Mapper; | ||
import org.apache.ibatis.annotations.Param; | ||
|
||
@Mapper | ||
public interface OrderQueryMapper { | ||
|
||
OrderEntityForOrderApproveValidation findOrderEntityForOrderApproveValidation(@Param("orderUuid") byte[] orderUuid); | ||
} |
26 changes: 26 additions & 0 deletions
26
src/main/java/com/hcommerce/heecommerce/order/OrderQueryRepository.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package com.hcommerce.heecommerce.order; | ||
|
||
import com.hcommerce.heecommerce.common.utils.TypeConversionUtils; | ||
import java.util.UUID; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.stereotype.Repository; | ||
|
||
@Repository | ||
public class OrderQueryRepository { | ||
|
||
private final OrderQueryMapper orderQueryMapper; | ||
|
||
@Autowired | ||
public OrderQueryRepository(OrderQueryMapper orderQueryMapper) { | ||
this.orderQueryMapper = orderQueryMapper; | ||
} | ||
|
||
public OrderEntityForOrderApproveValidation findOrderEntityForOrderApproveValidation(String orderId) { | ||
|
||
UUID orderUuid = UUID.fromString(orderId); | ||
|
||
byte[] orderUuidByte = TypeConversionUtils.convertUuidToBinary(orderUuid); | ||
|
||
return orderQueryMapper.findOrderEntityForOrderApproveValidation(orderUuidByte); | ||
} | ||
} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" | ||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> | ||
<mapper namespace="com.hcommerce.heecommerce.order.OrderQueryMapper"> | ||
|
||
<!-- 주문 검증을 위해 주문 조회 --> | ||
<select id="findOrderEntityForOrderApproveValidation" resultType="OrderEntityForOrderApproveValidation"> | ||
SELECT deal_product_uuid, order_quantity, total_payment_amount, out_of_stock_handling_option FROM `order` WHERE uuid = #{orderUuid} | ||
</select> | ||
</mapper> |
This file contains 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
This file contains 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
Oops, something went wrong.