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