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.web.dto.request.PaymentRequest;
|
||||
import roomescape.payment.SampleTossPaymentConst.amount
|
||||
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(
|
||||
"5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1", "MC4wODU4ODQwMzg4NDk0", 1000L, "카드");
|
||||
@JvmField
|
||||
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",
|
||||
"orderId": "MC4wODU4ODQwMzg4NDk0",
|
||||
"amount": 1000,
|
||||
"paymentType": "카드"
|
||||
"paymentKey": "$paymentKey",
|
||||
"orderId": "$orderId",
|
||||
"amount": $amount,
|
||||
"paymentType": "$paymentType"
|
||||
}
|
||||
""";
|
||||
""".trimIndent()
|
||||
|
||||
public static final PaymentCancelRequest cancelRequest = new PaymentCancelRequest(
|
||||
"5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1", 1000L, "테스트 결제 취소");
|
||||
@JvmField
|
||||
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",
|
||||
"message": "Error message"
|
||||
}
|
||||
""";
|
||||
}
|
||||
""".trimIndent()
|
||||
|
||||
public static final String confirmJson = """
|
||||
@JvmField
|
||||
val confirmJson: String = """
|
||||
{
|
||||
"mId": "tosspayments",
|
||||
"lastTransactionKey": "9C62B18EEF0DE3EB7F4422EB6D14BC6E",
|
||||
"paymentKey": "5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1",
|
||||
"orderId": "MC4wODU4ODQwMzg4NDk0",
|
||||
"paymentKey": "$paymentKey",
|
||||
"orderId": "$orderId",
|
||||
"orderName": "토스 티셔츠 외 2건",
|
||||
"taxExemptionAmount": 0,
|
||||
"status": "DONE",
|
||||
@ -88,22 +117,24 @@ public class SampleTossPaymentConst {
|
||||
"url": "https://api.tosspayments.com/v1/payments/5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1/checkout"
|
||||
},
|
||||
"currency": "KRW",
|
||||
"totalAmount": 1000,
|
||||
"balanceAmount": 1000,
|
||||
"suppliedAmount": 909,
|
||||
"vat": 91,
|
||||
"totalAmount": $amount,
|
||||
"balanceAmount": $amount,
|
||||
"suppliedAmount": ${(amount / 1.1).roundToLong()},
|
||||
"vat": ${amount - (amount / 1.1).roundToLong()},
|
||||
"taxFreeAmount": 0,
|
||||
"method": "카드",
|
||||
"method": "$paymentType",
|
||||
"version": "2022-11-16"
|
||||
}
|
||||
""";
|
||||
|
||||
""".trimIndent()
|
||||
|
||||
public static final String cancelJson = """
|
||||
@JvmField
|
||||
val cancelJson: String = """
|
||||
{
|
||||
"mId": "tosspayments",
|
||||
"lastTransactionKey": "090A796806E726BBB929F4A2CA7DB9A7",
|
||||
"paymentKey": "5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1",
|
||||
"orderId": "MC4wODU4ODQwMzg4NDk0",
|
||||
"paymentKey": "$paymentKey",
|
||||
"orderId": "$orderId",
|
||||
"orderName": "토스 티셔츠 외 2건",
|
||||
"taxExemptionAmount": 0,
|
||||
"status": "CANCELED",
|
||||
@ -135,12 +166,12 @@ public class SampleTossPaymentConst {
|
||||
"cancels": [
|
||||
{
|
||||
"transactionKey": "090A796806E726BBB929F4A2CA7DB9A7",
|
||||
"cancelReason": "테스트 결제 취소",
|
||||
"cancelReason": "$cancelReason",
|
||||
"taxExemptionAmount": 0,
|
||||
"canceledAt": "2024-02-13T12:20:23+09:00",
|
||||
"easyPayDiscountAmount": 0,
|
||||
"receiptKey": null,
|
||||
"cancelAmount": 1000,
|
||||
"cancelAmount": $amount,
|
||||
"taxFreeAmount": 0,
|
||||
"refundableAmount": 0,
|
||||
"cancelStatus": "DONE",
|
||||
@ -166,13 +197,18 @@ public class SampleTossPaymentConst {
|
||||
"url": "https://api.tosspayments.com/v1/payments/5EnNZRJGvaBX7zk2yd8ydw26XvwXkLrx9POLqKQjmAw4b0e1/checkout"
|
||||
},
|
||||
"currency": "KRW",
|
||||
"totalAmount": 1000,
|
||||
"totalAmount": $amount,
|
||||
"balanceAmount": 0,
|
||||
"suppliedAmount": 0,
|
||||
"vat": 0,
|
||||
"taxFreeAmount": 0,
|
||||
"method": "카드",
|
||||
"method": "$paymentType",
|
||||
"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.RoomescapeException;
|
||||
import roomescape.payment.SampleTossPaymentConst;
|
||||
import roomescape.payment.web.dto.request.PaymentCancelRequest;
|
||||
import roomescape.payment.web.dto.request.PaymentRequest;
|
||||
import roomescape.payment.web.dto.response.PaymentCancelResponse;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user