Exemplo n.º 1
0
        public void ConsumeOwnedPurchases()
        {
            if (iapAvailable != true)
            {
                OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE);
                return;
            }

            OwnedPurchasesReq ownedPurchasesReq = new OwnedPurchasesReq();

            ITask <OwnedPurchasesResult> task = iapClient.ObtainOwnedPurchases(ownedPurchasesReq);

            task.AddOnSuccessListener((result) =>
            {
                Debug.Log("HMSP: recoverPurchases");
                foreach (string inAppPurchaseData in result.InAppPurchaseDataList)
                {
                    ConsumePurchaseWithPurchaseData(inAppPurchaseData);
                    Debug.Log("HMSP: recoverPurchases result> " + result.ReturnCode);
                }

                OnRecoverPurchasesSuccess?.Invoke();
            }).AddOnFailureListener((exception) =>
            {
                Debug.Log($"HMSP: Error on recoverPurchases {exception.StackTrace}");
                OnRecoverPurchasesFailure?.Invoke(exception);
            });
        }
Exemplo n.º 2
0
        public void ConsumeOwnedPurchases()
        {
            if (iapAvailable != true)
            {
                OnRecoverPurchasesFailure?.Invoke(IAP_NOT_AVAILABLE);
                return;
            }

            OwnedPurchasesReq ownedPurchasesReq = new OwnedPurchasesReq();

            ITask <OwnedPurchasesResult> task = iapClient.ObtainOwnedPurchases(ownedPurchasesReq);

            task.AddOnSuccessListener((result) =>
            {
                Debug.Log("[HMSIAPManager] recoverPurchases");
                foreach (var inAppPurchaseData in result.InAppPurchaseDataList)
                {
                    ConsumePurchaseWithPurchaseData(inAppPurchaseData);
                    Debug.Log("[HMSIAPManager] recoverPurchases result> " + result.ReturnCode);
                }

                OnRecoverPurchasesSuccess?.Invoke();
            }).AddOnFailureListener((exception) =>
            {
                Debug.LogError("[HMSIAPManager] ConsumeOwnedPurchases failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage);
                OnRecoverPurchasesFailure?.Invoke(exception);
            });
        }