Hi,
We’ve been working on implementing UnityIAP for purchasing non-consumables in our game. The implementation is basically a MonoBehaviour that implements IStoreListener and initializes on Start(). Purchasing non-consumable products works on both iOS and Android. We have an IsPurchased() method that locally validates receipts by using CrossPlatformValidator.
We’ve noticed when the device has multiple Google accounts signed in at the system level only one account needs to have the non-consumable product purchased in order for every account on the device to be awarded the product. Calling Validate() on an instance of CrossPlatformValidator returns true no matter what account is playing the game or logged in anywhere.
Product product = _storeController.products.WithID(idString);
if (product.hasReceipt)
{
var validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.identifier);
var productReceipt = validator.Validate(product.receipt);
foreach (IPurchaseReceipt purchaseReceipt in productReceipt)
{
if (purchaseReceipt.productID.Equals(idString))
{
isAvailable = true;
break;
}
}
For testing purposes we’re using two accounts: account A has bought the product, account B has not. Both accounts are logged in on the same device under Settings → Accounts.
So far we’ve tried installing the game with account A or B, switching between users (on the GPGS level and in the Play Store app) and killing and then restarting the game after each login. The product is awarded to every account as if they all bought it.
The only way we managed to not allow account B to register as if it bought the product is by removing account A from the device altogether.
Logging into a different, new device with only account A awards the product as expected. Purchase history seems to initialize properly on a new device.
Logging into a new device with only account B after it was logged in with A on a device doesn’t award the product to account B, also as expected. There is no “cross-talk” from one account to the other when they are logged in together on one device. B never actually gets rights to the product without buying it.
It seems like the receipt for the product is saved locally and its state isn’t easily refreshed. Could we be able to clear local receipts somehow and re-check what the current user has bought? Maybe on startup or at will?
If not, users could easily create a single Google account, buy all the in-apps once and share it between themselves if they want. They don’t even have to be logged in and can get achievements and rank on leaderboards on their own accounts while doing this.
Thanks a bunch!