From 9d7bd8e9abbaa50809bdf9f218422ed438742719 Mon Sep 17 00:00:00 2001 From: Klaus Date: Sat, 29 Jun 2024 19:00:16 +0900 Subject: [PATCH] =?UTF-8?q?PG=EA=B2=B0=EC=A0=9C=20-=20=ED=97=A5=ED=86=A0?= =?UTF-8?q?=ED=8C=8C=EC=9D=B4=EB=82=B8=EC=85=9C=20=EA=B2=80=EC=A6=9D?= =?UTF-8?q?=EC=BD=94=EB=93=9C=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sodalive/can/charge/ChargeController.kt | 6 +++ .../sodalive/can/charge/ChargeService.kt | 44 +++++++++++++++++++ .../can/charge/temp/ChargeTempService.kt | 4 +- .../sodalive/explorer/ExplorerService.kt | 5 +-- src/main/resources/application.yml | 2 + 5 files changed, 55 insertions(+), 6 deletions(-) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt index 53c0eca..cd6b8da 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/ChargeController.kt @@ -33,6 +33,12 @@ class ChargeController(private val service: ChargeService) { @AuthenticationPrincipal user: User ) = ApiResponse.ok(service.verify(user, verifyRequest)) + @PostMapping("/verify/hecto") + fun verifyHecto( + @RequestBody verifyRequest: VerifyRequest, + @AuthenticationPrincipal user: User + ) = ApiResponse.ok(service.verifyHecto(user, verifyRequest)) + @PostMapping("/apple") fun appleCharge( @RequestBody chargeRequest: AppleChargeRequest, 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 57bf8a9..f65c389 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 @@ -45,6 +45,10 @@ class ChargeService( private val bootpayApplicationId: String, @Value("\${bootpay.private-key}") private val bootpayPrivateKey: String, + @Value("\${bootpay.hecto-application-id}") + private val bootpayHectoApplicationId: String, + @Value("\${bootpay.hecto-private-key}") + private val bootpayHectoPrivateKey: String, @Value("\${apple.iap-verify-sandbox-url}") private val appleInAppVerifySandBoxUrl: String, @Value("\${apple.iap-verify-url}") @@ -137,6 +141,46 @@ class ChargeService( } } + @Transactional + fun verifyHecto(user: User, verifyRequest: VerifyRequest) { + val charge = chargeRepository.findByIdOrNull(verifyRequest.orderId.toLong()) + ?: throw SodaException("결제정보에 오류가 있습니다.") + val member = memberRepository.findByEmail(user.username) + ?: throw SodaException("로그인 정보를 확인해주세요.") + + if (charge.payment!!.paymentGateway == PaymentGateway.PG) { + val bootpay = Bootpay(bootpayHectoApplicationId, bootpayHectoPrivateKey) + + try { + bootpay.accessToken + val verifyResult = objectMapper.convertValue( + bootpay.getReceipt(verifyRequest.receiptId), + VerifyResult::class.java + ) + + if (verifyResult.status == 1 && verifyResult.price == charge.can?.price) { + charge.payment?.receiptId = verifyResult.receiptId + charge.payment?.method = verifyResult.method + charge.payment?.status = PaymentStatus.COMPLETE + member.charge(charge.chargeCan, charge.rewardCan, "pg") + + applicationEventPublisher.publishEvent( + ChargeSpringEvent( + chargeId = charge.id!!, + memberId = member.id!! + ) + ) + } else { + throw SodaException("결제정보에 오류가 있습니다.") + } + } catch (e: Exception) { + throw SodaException("결제정보에 오류가 있습니다.") + } + } else { + throw SodaException("결제정보에 오류가 있습니다.") + } + } + @Transactional fun appleCharge(member: Member, request: AppleChargeRequest): ChargeResponse { val charge = Charge(request.chargeCan, 0) diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt index a578dac..8e2e645 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/can/charge/temp/ChargeTempService.kt @@ -28,9 +28,9 @@ class ChargeTempService( private val objectMapper: ObjectMapper, - @Value("\${bootpay.application-id}") + @Value("\${bootpay.hecto-application-id}") private val bootpayApplicationId: String, - @Value("\${bootpay.private-key}") + @Value("\${bootpay.hecto-private-key}") private val bootpayPrivateKey: String ) { diff --git a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt index 20921fb..f6c620f 100644 --- a/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt +++ b/src/main/kotlin/kr/co/vividnext/sodalive/explorer/ExplorerService.kt @@ -301,11 +301,9 @@ class ExplorerService( member: Member, pageable: Pageable ): GetFollowerListResponse { - val totalCount = queryRepository - .getFollowerListTotalCount(creatorId) + val totalCount = queryRepository.getFollowerListTotalCount(creatorId) val followerList = queryRepository.getFollowerList(creatorId, pageable.offset, pageable.pageSize.toLong()) - .asSequence() .map { val isFollow = if (it.role == MemberRole.CREATOR) { queryRepository.isFollow(creatorId = it.userId, memberId = member.id!!) @@ -320,7 +318,6 @@ class ExplorerService( isFollow = isFollow ) } - .toList() return GetFollowerListResponse(totalCount = totalCount, items = followerList) } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 62f24c6..6dc7c92 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -11,6 +11,8 @@ logging: bootpay: applicationId: ${BOOTPAY_APPLICATION_ID} privateKey: ${BOOTPAY_PRIVATE_KEY} + hectoApplicationId: ${BOOTPAY_APPLICATION_HECTO_ID} + hectoPrivateKey: ${BOOTPAY_PRIVATE_HECTO_KEY} apple: iapVerifyUrl: https://buy.itunes.apple.com/verifyReceipt