From 31b33fcbb7655aed5e78a7c4b273095e9947c0cd Mon Sep 17 00:00:00 2001 From: Wojtek Bauman Date: Mon, 7 Sep 2020 15:11:48 +0200 Subject: [PATCH] Pass initial user account id to the user app when purchasing subscription for the first time --- .../yaak/domain/googleplay/GooglePlaySubscriptionService.kt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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 0e85196..a18e59a 100644 --- a/src/main/kotlin/com/dietmap/yaak/domain/googleplay/GooglePlaySubscriptionService.kt +++ b/src/main/kotlin/com/dietmap/yaak/domain/googleplay/GooglePlaySubscriptionService.kt @@ -22,6 +22,7 @@ import java.math.BigDecimal class GooglePlaySubscriptionService(val androidPublisherApiClient: AndroidPublisher, val userAppClient: UserAppClient) { private val PAYMENT_RECEIVED_CODE = 1 private val PAYMENT_FREE_TRIAL_CODE = 2 + private val USER_ACCOUNT_ID_KEY = "obfuscatedExternalAccountId" private val logger = KotlinLogging.logger { } fun handlePurchase(purchaseRequest: PurchaseRequest, initialPurchase: Boolean = true): SubscriptionPurchase? { @@ -54,7 +55,7 @@ class GooglePlaySubscriptionService(val androidPublisherApiClient: AndroidPublis originalTransactionId = toInitialOrderId(subscription.orderId), productId = purchaseRequest.subscriptionId, description = "Google Play ${if (initialPurchase) "initial" else "renewal"} subscription order", - orderingUserId = purchaseRequest.orderingUserId, + orderingUserId = purchaseRequest.orderingUserId ?: subscription[USER_ACCOUNT_ID_KEY] as String?, discountCode = purchaseRequest.discountCode, expiryTimeMillis = subscription.expiryTimeMillis, googlePlayPurchaseDetails = GooglePlayPurchaseDetails(purchaseRequest.packageName, purchaseRequest.subscriptionId, purchaseRequest.purchaseToken)