feat(charge): 캔 충전시 통화(KRW, USD)별로 분기 처리
This commit is contained in:
@@ -72,6 +72,14 @@ class ChargeService(
|
||||
private val payverseClientKey: String,
|
||||
@Value("\${payverse.secret-key}")
|
||||
private val payverseSecretKey: String,
|
||||
|
||||
@Value("\${payverse.usd-mid}")
|
||||
private val payverseUsdMid: String,
|
||||
@Value("\${payverse.usd-client-key}")
|
||||
private val payverseUsdClientKey: String,
|
||||
@Value("\${payverse.usd-secret-key}")
|
||||
private val payverseUsdSecretKey: String,
|
||||
|
||||
@Value("\${payverse.host}")
|
||||
private val payverseHost: String,
|
||||
|
||||
@@ -96,8 +104,16 @@ class ChargeService(
|
||||
val expectedSign = DigestUtils.sha512Hex(
|
||||
String.format(
|
||||
"||%s||%s||%s||%s||%s||",
|
||||
payverseSecretKey,
|
||||
payverseMid,
|
||||
if (request.requestCurrency == "KRW") {
|
||||
payverseSecretKey
|
||||
} else {
|
||||
payverseUsdSecretKey
|
||||
},
|
||||
if (request.requestCurrency == "KRW") {
|
||||
payverseMid
|
||||
} else {
|
||||
payverseUsdMid
|
||||
},
|
||||
request.orderId,
|
||||
request.requestAmount,
|
||||
request.approvalDay
|
||||
@@ -218,6 +234,24 @@ class ChargeService(
|
||||
val can = canRepository.findByIdOrNull(request.canId)
|
||||
?: throw SodaException("잘못된 요청입니다\n앱 종료 후 다시 시도해 주세요.")
|
||||
|
||||
val requestCurrency = can.currency
|
||||
val isKrw = requestCurrency == "KRW"
|
||||
val mid = if (isKrw) {
|
||||
payverseMid
|
||||
} else {
|
||||
payverseUsdMid
|
||||
}
|
||||
val clientKey = if (isKrw) {
|
||||
payverseClientKey
|
||||
} else {
|
||||
payverseUsdClientKey
|
||||
}
|
||||
val secretKey = if (isKrw) {
|
||||
payverseSecretKey
|
||||
} else {
|
||||
payverseUsdSecretKey
|
||||
}
|
||||
|
||||
val charge = Charge(can.can, can.rewardCan)
|
||||
charge.title = can.title
|
||||
charge.member = member
|
||||
@@ -233,14 +267,20 @@ class ChargeService(
|
||||
val amount = savedCharge.payment!!.price
|
||||
val reqDate = savedCharge.createdAt!!.format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"))
|
||||
val sign = DigestUtils.sha512Hex(
|
||||
String.format("||%s||%s||%s||%s||%s||", payverseSecretKey, payverseMid, chargeId, amount, reqDate)
|
||||
String.format(
|
||||
"||%s||%s||%s||%s||%s||",
|
||||
secretKey,
|
||||
mid,
|
||||
chargeId,
|
||||
amount,
|
||||
reqDate
|
||||
)
|
||||
)
|
||||
val customerId = "${serverEnv}_user_${member.id!!}"
|
||||
val requestCurrency = "KRW"
|
||||
|
||||
val payload = linkedMapOf(
|
||||
"mid" to payverseMid,
|
||||
"clientKey" to payverseClientKey,
|
||||
"mid" to mid,
|
||||
"clientKey" to clientKey,
|
||||
"orderId" to chargeId.toString(),
|
||||
"customerId" to customerId,
|
||||
"productName" to can.title,
|
||||
@@ -261,6 +301,18 @@ class ChargeService(
|
||||
val member = memberRepository.findByIdOrNull(memberId)
|
||||
?: throw SodaException("로그인 정보를 확인해주세요.")
|
||||
|
||||
val isKrw = charge.can?.currency == "KRW"
|
||||
val mid = if (isKrw) {
|
||||
payverseMid
|
||||
} else {
|
||||
payverseUsdMid
|
||||
}
|
||||
val clientKey = if (isKrw) {
|
||||
payverseClientKey
|
||||
} else {
|
||||
payverseUsdClientKey
|
||||
}
|
||||
|
||||
// 결제수단 확인
|
||||
if (charge.payment?.paymentGateway != PaymentGateway.PAYVERSE) {
|
||||
throw SodaException("결제정보에 오류가 있습니다.")
|
||||
@@ -273,8 +325,8 @@ class ChargeService(
|
||||
val url = "$payverseHost/payment/search/transaction/${verifyRequest.transactionId}"
|
||||
val request = Request.Builder()
|
||||
.url(url)
|
||||
.addHeader("mid", payverseMid)
|
||||
.addHeader("clientKey", payverseClientKey)
|
||||
.addHeader("mid", mid)
|
||||
.addHeader("clientKey", clientKey)
|
||||
.get()
|
||||
.build()
|
||||
|
||||
|
@@ -15,11 +15,14 @@ weraser:
|
||||
apiKey: ${WERASER_API_KEY}
|
||||
|
||||
payverse:
|
||||
host: ${PAYVERSE_HOST}
|
||||
inboundIp: ${PAYVERSE_INBOUND_IP}
|
||||
mid: ${PAYVERSE_MID}
|
||||
clientKey: ${PAYVERSE_CLIENT_KEY}
|
||||
secretKey: ${PAYVERSE_SECRET_KEY}
|
||||
host: ${PAYVERSE_HOST}
|
||||
inboundIp: ${PAYVERSE_INBOUND_IP}
|
||||
usdMid: ${PAYVERSE_USD_MID}
|
||||
usdClientKey: ${PAYVERSE_USD_CLIENT_KEY}
|
||||
usdSecretKey: ${PAYVERSE_USD_SECRET_KEY}
|
||||
|
||||
bootpay:
|
||||
applicationId: ${BOOTPAY_APPLICATION_ID}
|
||||
|
Reference in New Issue
Block a user