generated from pricelees/issue-pr-template
refactor: 테스트에서 쓰이는 샘플 응답 상수 클래스인 SampleTossPaymentConst의 코틀린 전환
This commit is contained in:
parent
62d3f859ac
commit
3193a905db
@ -1,44 +1,73 @@
|
|||||||
package roomescape.payment.infrastructure.client;
|
package roomescape.payment
|
||||||
|
|
||||||
import roomescape.payment.web.dto.request.PaymentCancelRequest;
|
import roomescape.payment.SampleTossPaymentConst.amount
|
||||||
import roomescape.payment.web.dto.request.PaymentRequest;
|
import roomescape.payment.web.dto.request.PaymentCancelRequest
|
||||||
|
import roomescape.payment.web.dto.request.PaymentRequest
|
||||||
|
import kotlin.math.roundToLong
|
||||||
|
|
||||||
public class SampleTossPaymentConst {
|
object SampleTossPaymentConst {
|
||||||
|
@JvmField
|
||||||
|
val paymentKey: String = "5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1"
|
||||||
|
|
||||||
public static final PaymentRequest paymentRequest = new PaymentRequest(
|
@JvmField
|
||||||
"5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1", "MC4wODU4ODQwMzg4NDk0", 1000L, "카드");
|
val orderId: String = "MC4wODU4ODQwMzg4NDk0"
|
||||||
|
|
||||||
public static final String paymentRequestJson = """
|
@JvmField
|
||||||
|
val amount: Long = 1000L
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val paymentType: String = "카드"
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val cancelReason: String = "테스트 결제 취소"
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val paymentRequest: PaymentRequest = PaymentRequest(
|
||||||
|
paymentKey,
|
||||||
|
orderId,
|
||||||
|
amount,
|
||||||
|
paymentType
|
||||||
|
)
|
||||||
|
|
||||||
|
@JvmField
|
||||||
|
val paymentRequestJson: String = """
|
||||||
{
|
{
|
||||||
"paymentKey": "5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1",
|
"paymentKey": "$paymentKey",
|
||||||
"orderId": "MC4wODU4ODQwMzg4NDk0",
|
"orderId": "$orderId",
|
||||||
"amount": 1000,
|
"amount": $amount,
|
||||||
"paymentType": "카드"
|
"paymentType": "$paymentType"
|
||||||
}
|
}
|
||||||
""";
|
""".trimIndent()
|
||||||
|
|
||||||
public static final PaymentCancelRequest cancelRequest = new PaymentCancelRequest(
|
@JvmField
|
||||||
"5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1", 1000L, "테스트 결제 취소");
|
val cancelRequest: PaymentCancelRequest = PaymentCancelRequest(
|
||||||
|
paymentKey,
|
||||||
|
amount,
|
||||||
|
cancelReason
|
||||||
|
)
|
||||||
|
|
||||||
public static final String cancelRequestJson = """
|
@JvmField
|
||||||
|
val cancelRequestJson: String = """
|
||||||
{
|
{
|
||||||
"cancelReason": "테스트 결제 취소"
|
"cancelReason": "$cancelReason"
|
||||||
}
|
}
|
||||||
""";
|
""".trimIndent()
|
||||||
|
|
||||||
public static final String tossPaymentErrorJson = """
|
@JvmField
|
||||||
|
val tossPaymentErrorJson: String = """
|
||||||
{
|
{
|
||||||
"code": "ERROR_CODE",
|
"code": "ERROR_CODE",
|
||||||
"message": "Error message"
|
"message": "Error message"
|
||||||
}
|
}
|
||||||
""";
|
""".trimIndent()
|
||||||
|
|
||||||
public static final String confirmJson = """
|
@JvmField
|
||||||
|
val confirmJson: String = """
|
||||||
{
|
{
|
||||||
"mId": "tosspayments",
|
"mId": "tosspayments",
|
||||||
"lastTransactionKey": "9C62B18EEF0DE3EB7F4422EB6D14BC6E",
|
"lastTransactionKey": "9C62B18EEF0DE3EB7F4422EB6D14BC6E",
|
||||||
"paymentKey": "5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1",
|
"paymentKey": "$paymentKey",
|
||||||
"orderId": "MC4wODU4ODQwMzg4NDk0",
|
"orderId": "$orderId",
|
||||||
"orderName": "토스 티셔츠 외 2건",
|
"orderName": "토스 티셔츠 외 2건",
|
||||||
"taxExemptionAmount": 0,
|
"taxExemptionAmount": 0,
|
||||||
"status": "DONE",
|
"status": "DONE",
|
||||||
@ -88,22 +117,24 @@ public class SampleTossPaymentConst {
|
|||||||
"url": "https://api.tosspayments.com/v1/payments/5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1/checkout"
|
"url": "https://api.tosspayments.com/v1/payments/5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1/checkout"
|
||||||
},
|
},
|
||||||
"currency": "KRW",
|
"currency": "KRW",
|
||||||
"totalAmount": 1000,
|
"totalAmount": $amount,
|
||||||
"balanceAmount": 1000,
|
"balanceAmount": $amount,
|
||||||
"suppliedAmount": 909,
|
"suppliedAmount": ${(amount / 1.1).roundToLong()},
|
||||||
"vat": 91,
|
"vat": ${amount - (amount / 1.1).roundToLong()},
|
||||||
"taxFreeAmount": 0,
|
"taxFreeAmount": 0,
|
||||||
"method": "카드",
|
"method": "$paymentType",
|
||||||
"version": "2022-11-16"
|
"version": "2022-11-16"
|
||||||
}
|
}
|
||||||
""";
|
|
||||||
|
""".trimIndent()
|
||||||
|
|
||||||
public static final String cancelJson = """
|
@JvmField
|
||||||
|
val cancelJson: String = """
|
||||||
{
|
{
|
||||||
"mId": "tosspayments",
|
"mId": "tosspayments",
|
||||||
"lastTransactionKey": "090A796806E726BBB929F4A2CA7DB9A7",
|
"lastTransactionKey": "090A796806E726BBB929F4A2CA7DB9A7",
|
||||||
"paymentKey": "5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1",
|
"paymentKey": "$paymentKey",
|
||||||
"orderId": "MC4wODU4ODQwMzg4NDk0",
|
"orderId": "$orderId",
|
||||||
"orderName": "토스 티셔츠 외 2건",
|
"orderName": "토스 티셔츠 외 2건",
|
||||||
"taxExemptionAmount": 0,
|
"taxExemptionAmount": 0,
|
||||||
"status": "CANCELED",
|
"status": "CANCELED",
|
||||||
@ -135,12 +166,12 @@ public class SampleTossPaymentConst {
|
|||||||
"cancels": [
|
"cancels": [
|
||||||
{
|
{
|
||||||
"transactionKey": "090A796806E726BBB929F4A2CA7DB9A7",
|
"transactionKey": "090A796806E726BBB929F4A2CA7DB9A7",
|
||||||
"cancelReason": "테스트 결제 취소",
|
"cancelReason": "$cancelReason",
|
||||||
"taxExemptionAmount": 0,
|
"taxExemptionAmount": 0,
|
||||||
"canceledAt": "2024-02-13T12:20:23+09:00",
|
"canceledAt": "2024-02-13T12:20:23+09:00",
|
||||||
"easyPayDiscountAmount": 0,
|
"easyPayDiscountAmount": 0,
|
||||||
"receiptKey": null,
|
"receiptKey": null,
|
||||||
"cancelAmount": 1000,
|
"cancelAmount": $amount,
|
||||||
"taxFreeAmount": 0,
|
"taxFreeAmount": 0,
|
||||||
"refundableAmount": 0,
|
"refundableAmount": 0,
|
||||||
"cancelStatus": "DONE",
|
"cancelStatus": "DONE",
|
||||||
@ -166,13 +197,18 @@ public class SampleTossPaymentConst {
|
|||||||
"url": "https://api.tosspayments.com/v1/payments/5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1/checkout"
|
"url": "https://api.tosspayments.com/v1/payments/5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1/checkout"
|
||||||
},
|
},
|
||||||
"currency": "KRW",
|
"currency": "KRW",
|
||||||
"totalAmount": 1000,
|
"totalAmount": $amount,
|
||||||
"balanceAmount": 0,
|
"balanceAmount": 0,
|
||||||
"suppliedAmount": 0,
|
"suppliedAmount": 0,
|
||||||
"vat": 0,
|
"vat": 0,
|
||||||
"taxFreeAmount": 0,
|
"taxFreeAmount": 0,
|
||||||
"method": "카드",
|
"method": "$paymentType",
|
||||||
"version": "2022-11-16"
|
"version": "2022-11-16"
|
||||||
}
|
}
|
||||||
""";
|
|
||||||
|
""".trimIndent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
println((amount / 1.1).roundToLong())
|
||||||
|
}
|
||||||
@ -18,6 +18,7 @@ import org.springframework.test.web.client.MockRestServiceServer;
|
|||||||
|
|
||||||
import roomescape.common.exception.ErrorType;
|
import roomescape.common.exception.ErrorType;
|
||||||
import roomescape.common.exception.RoomescapeException;
|
import roomescape.common.exception.RoomescapeException;
|
||||||
|
import roomescape.payment.SampleTossPaymentConst;
|
||||||
import roomescape.payment.web.dto.request.PaymentCancelRequest;
|
import roomescape.payment.web.dto.request.PaymentCancelRequest;
|
||||||
import roomescape.payment.web.dto.request.PaymentRequest;
|
import roomescape.payment.web.dto.request.PaymentRequest;
|
||||||
import roomescape.payment.web.dto.response.PaymentCancelResponse;
|
import roomescape.payment.web.dto.response.PaymentCancelResponse;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user