From dd147cbdaf133c6dbe1ed39aff1387512a6097b7 Mon Sep 17 00:00:00 2001 From: Wojtek Bauman Date: Mon, 14 Sep 2020 16:39:32 +0200 Subject: [PATCH] Handle order verification failure add more logging expose separate port for monitoring (actuator) remove explicitly set Xms parameter --- build.gradle.kts | 4 ++-- .../domain/googleplay/GooglePlaySubscriptionService.kt | 9 ++++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index c4b9eea..6cf6095 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -84,8 +84,8 @@ jib { labels = mapOf( "maintainer" to "Krzysztof Koziol" ) - jvmFlags = listOf("-Xms512m", "-Djava.awt.headless=true") + jvmFlags = listOf("-Djava.awt.headless=true") mainClass = "com.dietmap.yaak.YaakApplicationKt" - ports = listOf("8080", "9090") + ports = listOf("8080", "8778", "9090") } } \ No newline at end of file diff --git a/src/main/kotlin/com/dietmap/yaak/domain/googleplay/GooglePlaySubscriptionService.kt b/src/main/kotlin/com/dietmap/yaak/domain/googleplay/GooglePlaySubscriptionService.kt index 6043e2e..4b2bcab 100644 --- a/src/main/kotlin/com/dietmap/yaak/domain/googleplay/GooglePlaySubscriptionService.kt +++ b/src/main/kotlin/com/dietmap/yaak/domain/googleplay/GooglePlaySubscriptionService.kt @@ -87,11 +87,18 @@ class GooglePlaySubscriptionService(val androidPublisherApiClient: AndroidPublis fun verifyOrders(orders: Collection): Boolean { orders - .map(::handlePurchase) + .map(::tryToVerifyOrder) .also { logger.info { "Verified ${it.size} user orders" } } return userAppClient.checkSubscription()?.status == USER_APP_STATUS_ACTIVE } + private fun tryToVerifyOrder(purchaseRequest: PurchaseRequest) = try { + logger.debug { "About to verify user order: $purchaseRequest" } + handlePurchase(purchaseRequest) + } catch (e: Exception) { + logger.error(e) { "Error during verification of user order" } + } + private fun handleStatusUpdate(packageName: String, notification: GooglePlaySubscriptionNotification) { val subscription = androidPublisherApiClient.Purchases().Subscriptions().get(packageName, notification.subscriptionId, notification.purchaseToken).execute() logger.debug { "Google Play subscription details: $subscription" }