Skip to content

Commit

Permalink
Pass initial user account id to the user app when purchasing subscrip…
Browse files Browse the repository at this point in the history
…tion for the first time
  • Loading branch information
wojtekbauman committed Sep 7, 2020
1 parent 1b0a9b4 commit 31b33fc
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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? {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 31b33fc

Please sign in to comment.