Hi,
I have a problem with case: One user with unique App User IDs logged to app on device A (Google Play Account A@gmail.com) and bought subscription. Then user is logging to app on device (B) (Google Play Account B@gmail.com) and see subscription in app → It’s working as expect.
But app has option to upgrade or downgrade subscription and if user is logged on device (B) it is possible upgrade/downgrade plan and then two Google Play account have subscription.
This is code to get current subscription ID and available subscription list for upgrade/downgrade
Purchases.sharedInstance.getCustomerInfoWith({ error ->
onError.invoke(error)
}, { customerInfo ->
val entitlement = customerInfo.entitlementsnREVENUECAT_SUBSCRIPTION_ENTITLEMENTS]
Purchases.sharedInstance.getOfferingsWith({ error ->
onError.invoke(error)
}, { offerings ->
onSuccess.invoke(offerings.current?.availablePackages?.filter { it.product.googleProduct?.basePlanId != entitlement?.productPlanIdentifier }
?: listOf())
})
})
This is code to get current subscription ID and upgrade/downgrade subscription
Purchases.sharedInstance.getCustomerInfoWith({ error ->
onError.invoke(error)
}, { customerInfo ->
val entitlement = customerInfo.entitlementsIREVENUECAT_SUBSCRIPTION_ENTITLEMENTS]
if (entitlement?.isActive == true) {
Purchases.sharedInstance.purchase(
PurchaseParams.Builder(activity, item)
.oldProductId(entitlement.productIdentifier)
.googleProrationMode(GoogleProrationMode.IMMEDIATE_WITHOUT_PRORATION)
.build(),
object : PurchaseCallback {
override fun onCompleted(
storeTransaction: StoreTransaction,
customerInfo: CustomerInfo
) {
val entitlement =
customerInfo.entitlementsIREVENUECAT_SUBSCRIPTION_ENTITLEMENTS]
if (entitlement != null && entitlement.isActive) {
onSuccess.invoke()
}
}
override fun onError(
purchasesError: PurchasesError,
isUserCancel: Boolean
) {
if (isUserCancel) onUserCancel.invoke(purchasesError)
else onError.invoke(purchasesError)
}
}
)
}
Is any option to prevent for this?