From 6327a5d2bf5eec268cb9e8e814e8213911c8931a Mon Sep 17 00:00:00 2001 From: Klaus Date: Thu, 2 Oct 2025 18:59:52 +0900 Subject: [PATCH] =?UTF-8?q?feat(charge):=20=EC=BA=94=20=EC=B6=A9=EC=A0=84?= =?UTF-8?q?=EC=8B=9C=20=ED=86=B5=ED=99=94(KRW,=20USD)=EB=B3=84=EB=A1=9C=20?= =?UTF-8?q?=EB=B6=84=EA=B8=B0=20=EC=B2=98=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/can/charge/ChargeService.kt | 68 ++++++++++++++++--- src/main/resources/application.yml | 7 +- 2 files changed, 65 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt index 73beb86..ab466db 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeService.kt @@ -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() diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 15abb0b..c268ead 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -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}