Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

How to access IAppleExtensions for restoration of purchases for iOS (5.6.3p2)

Discussion in 'Scripting' started by hzhou1995, Dec 29, 2019.

  1. hzhou1995

    hzhou1995

    Joined:
    Dec 11, 2019
    Posts:
    6
    Hi there,

    I'm trying to implement a restore purchases button for iOS using the Codeless IAP asset. However, when I use to following code:
    Code (CSharp):
    1. IAppleExtensions extensions = IAPButton.IAPButtonStoreManager.Instance.ExtensionProvider.GetExtension<IAppleExtensions>();
    it says that "IAPButton does not contain a definition for IAPButtonStoreManager". I am following the example here: https://docs.unity3d.com/560/Documentation/Manual/UnityIAPCodelessIAP.html, specifically the "Apple App Store: Non-consumable purchase restoration example" section. Could someone please assist in accessing the IAppleExtensions class?

    Thanks!
     
  2. Neonlyte

    Neonlyte

    Joined:
    Oct 17, 2013
    Posts:
    505
    I checked my copy of IAP and there is no "IAPButtonStoreManager" property under IAPButton. They probably did not update the documentation.

    You probably want to access CodelessIAPStoreListener instead, since you look like using Codeless IAP:
    Code (CSharp):
    1. CodelessIAPStoreListener.Instance.ExtensionProvider.GetExtension<IAppleExtensions>();
    I'm on Unity IAP 1.23.1 BTW
     
  3. hzhou1995

    hzhou1995

    Joined:
    Dec 11, 2019
    Posts:
    6
    Hey! I think that worked, thank you so much! :)
     
  4. hzhou1995

    hzhou1995

    Joined:
    Dec 11, 2019
    Posts:
    6
    So just one more thing... when restoring transacations, the RestoreTransactions function is called and given a callback.
    Code (CSharp):
    1. extensions.RestoreTransactions(OnTransactionsRestored);
    How can I use this function to check the actual receipts received from the Apple App store? What does RestoreTransactions actually do? For example, if there are 3 non-consumables, I want to be able to match the receipts returned from restoration to the gameobjects in my game, but all it seems to return is a bool. If my understanding is correct, how can I access the receipts themselves that RestoreTransactions in theory should check for? What RestoreTransactions actually do? Thanks!
     
  5. hzhou1995

    hzhou1995

    Joined:
    Dec 11, 2019
    Posts:
    6
    According to this page:https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html, the paragraph that says:

    "On Apple platforms users must enter their password to retrieve previous transactions so your application must provide users with a button letting them do so. During this process the ProcessPurchase method of your IStoreListener will be invoked for any items the user already owns."

    Does this mean the receipt validation part is abstracted away? e.g. It'll just map whatever product IDs it receives from the App Store to the corresponding non-consumables in the scene and execute the OnPurchaseComplete event associated with the item?
     
  6. AminAghajoon

    AminAghajoon

    Joined:
    May 17, 2013
    Posts:
    20
    If you are using code api you can use `OnInitialized` parameters to get `extention provider`:

    Code (CSharp):
    1. public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    2. {
    3.     Debug.Log("In-App Purchasing successfully initialized");
    4.     m_AppleExtensions = extensions.GetExtension<IAppleExtensions>();
    5. }