Skip to content

Commit

Permalink
Merge pull request #53 from dietmap/handle-verification-failure
Browse files Browse the repository at this point in the history
Handle order verification failure
  • Loading branch information
wojtekbauman authored Sep 14, 2020
2 parents 92613a7 + dd147cb commit 28a2fd7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,18 @@ class GooglePlaySubscriptionService(val androidPublisherApiClient: AndroidPublis

fun verifyOrders(orders: Collection<PurchaseRequest>): 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" }
Expand Down

0 comments on commit 28a2fd7

Please sign in to comment.