Skip to content

Commit

Permalink
Merge pull request #50 from dietmap/initial-purchase-user-id
Browse files Browse the repository at this point in the history
Pass initial user account id to the user app when purchasing subscription
  • Loading branch information
wojtekbauman authored Sep 7, 2020
2 parents 1b0a9b4 + 31b33fc commit 2097aa0
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 2097aa0

Please sign in to comment.