// Restore purchases previously made by this customer. Some platforms automatically restore purchases, like Google.
    // Apple currently requires explicit purchase restoration for IAP, conditionally displaying a password prompt.
    public void RestorePurchases()
    {
#if !NO_IAP && UNITY_PURCHASING && (UNITY_IOS || UNITY_ANDROID)
        // If Purchasing has not yet been set up ...
        if (!IsPurchasingInitialized())
        {
            // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
            var errorMessage = "[" + TAG_RESTORE + "]: FAIL. Not initialized.";
            RestoreResult(false, errorMessage);
            return;
        }

        if (Application.platform == RuntimePlatform.WSAPlayerX86 || Application.platform == RuntimePlatform.WSAPlayerX64 || Application.platform == RuntimePlatform.WSAPlayerARM)
        {
            StoreExtensionProvider.GetExtension <IMicrosoftExtensions>().RestoreTransactions();
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.tvOS)
        {
            StoreExtensionProvider.GetExtension <IAppleExtensions>().RestoreTransactions(OnTransactionsRestored);
        }
        else
        {
            var errorMessage = "[" + TAG_RESTORE + "]: FAIL. Platform: " + Application.platform.ToString() + " is not a supported platform for the Codeless IAP restore button";
            RestoreResult(false, errorMessage);
        }
#else
        Debug.LogWarning("Cannot restore product, Unity Purchasing is not enabled.");
#endif
    }
示例#2
0
        /// <summary>
        /// Gets the current Amazon user ID (for other Amazon services).
        /// Only call this method after initialization has been done.
        /// Returns <c>null</c> if the current store is not Amazon store.
        /// </summary>
        /// <returns>The amazon user identifier.</returns>
        public static string GetAmazonUserId()
        {
            string userId = null;

            if (StoreExtensionProvider != null)
            {
                IAmazonExtensions aEtx = StoreExtensionProvider.GetExtension <IAmazonExtensions>();

                if (aEtx != null)
                {
                    userId = aEtx.amazonUserId;
                }
            }

            return(userId);
        }
示例#3
0
    // Restore purchases previously made by this customer. Some platforms automatically restore purchases, like Google.
    // Apple currently requires explicit purchase restoration for IAP, conditionally displaying a password prompt.
    public void RestorePurchases()
    {
#if (UNITY_ANDROID || UNITY_IOS) && UNITY_PURCHASING
        // If Purchasing has not yet been set up ...
        if (!IsPurchasingInitialized())
        {
            // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
            var errorMessage = "[" + TAG_RESTORE + "]: FAIL. Not initialized.";
            RestoreResult(false, errorMessage);
            return;
        }

        if (Application.platform == RuntimePlatform.WSAPlayerX86 || Application.platform == RuntimePlatform.WSAPlayerX64 || Application.platform == RuntimePlatform.WSAPlayerARM)
        {
            StoreExtensionProvider.GetExtension <IMicrosoftExtensions>().RestoreTransactions();
        }
        else if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer || Application.platform == RuntimePlatform.tvOS)
        {
            StoreExtensionProvider.GetExtension <IAppleExtensions>().RestoreTransactions(OnTransactionsRestored);
        }
        else if (Application.platform == RuntimePlatform.Android && StandardPurchasingModule.Instance().appStore == AppStore.SamsungApps)
        {
            StoreExtensionProvider.GetExtension <ISamsungAppsExtensions>().RestoreTransactions(OnTransactionsRestored);
        }
        else if (Application.platform == RuntimePlatform.Android && StandardPurchasingModule.Instance().appStore == AppStore.CloudMoolah)
        {
            StoreExtensionProvider.GetExtension <IMoolahExtension>().RestoreTransactionID((restoreTransactionIDState) =>
            {
                OnTransactionsRestored(restoreTransactionIDState != RestoreTransactionIDState.RestoreFailed && restoreTransactionIDState != RestoreTransactionIDState.NotKnown);
            });
        }
        else
        {
            var errorMessage = "[" + TAG_RESTORE + "]: FAIL. Platform: " + Application.platform.ToString() + " is not a supported platform for the Codeless IAP restore button";
            RestoreResult(false, errorMessage);
        }
#else
        Debug.LogWarning("Cannot restore product, Unity Purchasing is not enabled.");
#endif
    }