Search Unity

  1. Unity Asset Manager is now available in public beta. Try it out now and join the conversation here in the forums.
    Dismiss Notice

Restoring Transactions

Discussion in '5.3 Beta' started by atmuc, Nov 10, 2015.

  1. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i have an Android game. i bought an IAP Managed Product. Documentation says ProcessPurchase will be called after initialization. it does not call ProcessPurchase. do i miss something?
     
  2. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    Documentation says that ProcessPurchase will be called after initialization for purchases which are not finalized. So if your purchase workflow crashes in ProcessPurchase, it will be called on the next app launch again.
     
  3. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i read this local documentation. i could not find any word like finalized or pending there, so i thought it should be called for all successful transactions.

    file:///C:/Program%20Files/Unity%205.3.0b5/Editor/Data/Documentation/en/Manual/UnityIAPRestoringTransactions.html

    Assume that i have an IAP product to unlock a character in my game. If i save this in my player preferences user will lose if he uninstall and reinstall my game. should i save it on my server or should i save it as an hidden achievement using native API like Google Play?
     
    Last edited: Nov 11, 2015
  4. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    You are confusing the restore transactions design on Android and iOS.

    On Android you are receiving a list of all products after initialization directly from Google Play. This list contains whether a product has been purchased or not, so you can use that to restore your characters.

    iOS has a RestoreTransactions method which asks for the user's account password and fires ProcessPurchase for each product. The difference to Google Play is by design, Apple and Google simply work differently.
     
  5. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    Thanks Baroni for this info. i use IAP for the first time so it should be my mistake. i examined this page; file:///C:/Program%20Files/Unity%205.3.0b6/Editor/Data/Documentation/en/ScriptReference/Purchasing.Product.html

    for my purchased product item.hasReceipt.ToString(),item.receipt, item.transactionID fields are False,empty, empty

    My product is managed product. http://developer.android.com/google/play/billing/api.html#managed this page says i can consume it. i guess after i consume it i cannot see it as purchased. i bought it with my developer/application owner account. can this cause this? how can i check if i bought it or not? i can see credit card transaction for this purchase.it is at provisioning state at my bank.
     
  6. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    I noticed that i set product as ProductType.Consumable. Does unity consumes it automatically after purchase?
     
  7. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    i set it as nonconsumable.i bought it again. now it comes after initialization. it looks unity consumes immediately consumables. android has different call for this.
     
  8. atmuc

    atmuc

    Joined:
    Feb 28, 2011
    Posts:
    1,166
    I released Android version and started iOS integration. i managed to bought my product in sandbox. after initialization item.hasReceipt returns false. at android it is always true after purchase.i tried to purchase it again. ios said i have already purchased it and i can purchased it again as free. do Android and iOS work different on OnInitilatize by design or i do something wrong at iOS?
     
  9. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    With a little luck you will find another thread in the beta section which also mentions iOS product receipts being null after the app launches. This is probably going to change / get fixed, based on the reply of Banderous (Unity).