- Home /
ProcessPurchase not called on startup (Android)
Hi, I'm trying to get the Unity IAP system working on Android. Almost everything seems to work. But when I restart my app, the ProcessPurchase method is not called. Therefore the purchased items are not unlocked in-game. From what I can read in the documentation (https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html), this method should be called automatically.
The logcat output indicates the items are marked as 'owned'. But because the transaction is already recorded, it isn't processed again? How do I get Unity to call ProcessPurchase for these purchases?
EDIT: Okay, I just found out that it does work the first time the app starts after installing it. So it seems Unity assumes you locally keep track of what should be unlocked with the user's purchases? This seems more prone to users gaining content by modifying local data.
I/UnityIAP(25500): Starting in-app billing setup. I/UnityIAP(25500): Billing service connected. I/UnityIAP(25500): invoking callback I/UnityIAP(25500): Checking for in-app billing 3 support. I/UnityIAP(25500): In-app billing version 3 supported for com.grendelgames.garfield.dev I/UnityIAP(25500): Subscriptions AVAILABLE. I/UnityIAP(25500): onIabSetupFinished: 0 I/UnityIAP(25500): Requesting 5 products I/UnityIAP(25500): QueryInventory: 5 I/UnityIAP(25500): invoking callback I/UnityIAP(25500): Querying owned items, item type: inapp I/UnityIAP(25500): Package name: com.grendelgames.garfield.dev I/UnityIAP(25500): Calling getPurchases with continuation token: null I/UnityIAP(25500): Owned items response: 0 I/UnityIAP(25500): Sku is owned: com.grendelgames.garfield.venice I/UnityIAP(25500): Sku is owned: com.grendelgames.garfield.amsterdam I/UnityIAP(25500): Sku is owned: com.grendelgames.garfield.world_pass I/UnityIAP(25500): Continuation token: null I/UnityIAP(25500): Querying SKU details. I/UnityIAP(25500): Querying owned items, item type: subs I/UnityIAP(25500): Package name: com.grendelgames.garfield.dev I/UnityIAP(25500): Calling getPurchases with continuation token: null I/UnityIAP(25500): Owned items response: 0 I/UnityIAP(25500): Continuation token: null I/UnityIAP(25500): Querying SKU details. I/UnityIAP(25500): onQueryInventoryFinished: true I/UnityIAP(25500): Inventory refresh successful. (response: 0:OK) I/Unity (25500): Already recorded transaction kjeobmbgeedimmihldkgmhln.AO-J1OxXpvh1fbvFr52xxml7FfhNOurKv9J1D50dEtEZ5KNac-c450AH3LnGT1VJENIy0bHz9TlXFeDHTuMhyWD_Nq-7LCBrgnzUmuOExNak4qZC6-rb1YuUiKUDibEgXXAKe9c1FE7fhM5bgrgSTlU3WWEYh9erKucaFFKNKiwiPx2CqO81oKQ I/UnityIAP(25500): Finish transaction:kjeobmbgeedimmihldkgmhln.AO-J1OxXpvh1fbvFr52xxml7FfhNOurKv9J1D50dEtEZ5KNac-c450AH3LnGT1VJENIy0bHz9TlXFeDHTuMhyWD_Nq-7LCBrgnzUmuOExNak4qZC6-rb1YuUiKUDibEgXXAKe9c1FE7fhM5bgrgSTlU3WWEYh9erKucaFFKNKiwiPx2CqO81oKQ I/Unity (25500): Already recorded transaction hopfojbbnobcbjnhaddiioim.AO-J1Oxz0BcfyzBvzuLF9ewS07S_GGA1-7RxxuOYfpxApdSD4hCK0_0Z0TSGspJRQPCsJomyZQ3x30O246MMnL0Lhrv68ZV-KlnvQW9aeJX3aL5bKiqmIOA5u-NFIdRjrtqavWzl6sf5NxXn83j5bqFl-mG_ovQw_g I/UnityIAP(25500): Finish transaction:hopfojbbnobcbjnhaddiioim.AO-J1Oxz0BcfyzBvzuLF9ewS07S_GGA1-7RxxuOYfpxApdSD4hCK0_0Z0TSGspJRQPCsJomyZQ3x30O246MMnL0Lhrv68ZV-KlnvQW9aeJX3aL5bKiqmIOA5u-NFIdRjrtqavWzl6sf5NxXn83j5bqFl-mG_ovQw_g I/Unity (25500): Already recorded transaction docaedeeiifnldmgnhenblgd.AO-J1OyOtVQdvUibLO10J1UGJkuAGEnDHKZ1BHuIXUNUWZpyJ2D-i2wiI3du6jw7UNHNPOWonz-g2UQQXpR2J5_4Pe4bR-JIuQ99Pvqh0_pdDvYBWu0aJkH7bsp8Co7FaTY8OmUjCHXdC8Nfo1vJoIUM-AaO2_ArFwf1yUHp-ATcGc4NwWloj60
Answer by Magicware · Dec 12, 2016 at 08:13 AM
Same issue here. Check this out: https://forum.unity3d.com/threads/restore-purchases-not-working-in-unity-iap-android.418919/
Answer by Kurius · Jun 23, 2017 at 07:18 PM
Here's one solution... https://forum.unity3d.com/threads/restore-transactions-via-codeless-iap.479251/