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); }); }
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); }); }
//void LoadOwnedConsumables() //{ // CreateOwnedPerchaseRequest(HuaweiConstants.IAP.IapType.CONSUMABLE, LoadOwnedNonConsumables); //} //void LoadOwnedNonConsumables() //{ // CreateOwnedPerchaseRequest(HuaweiConstants.IAP.IapType.NON_CONSUMABLE, LoadOwnedSubscribes); //} //void LoadOwnedSubscribes() //{ // CreateOwnedPerchaseRequest(HuaweiConstants.IAP.IapType.SUBSCRIPTION, ProductsLoaded); //} void CreateOwnedPerchaseRequest(HuaweiConstants.IAP.IapType type, System.Action onSuccess) { var ownedPurchasesReq = new OwnedPurchasesReq(); ownedPurchasesReq.PriceType = (int)type; var task = iapClient.ObtainOwnedPurchases(ownedPurchasesReq); task.AddOnSuccessListener((result) => { ParseOwned(result); onSuccess(); }); }
private void recoverPurchases() { OwnedPurchasesReq ownedPurchasesReq = new OwnedPurchasesReq(); ITask <OwnedPurchasesResult> task = iapClient.ObtainOwnedPurchases(ownedPurchasesReq); task.AddOnSuccessListener((result) => { Debug.Log("HMSP: recoverPurchases"); foreach (string inAppPurchaseData in result.InAppPurchaseDataList) { InAppPurchaseData inAppPurchaseDataBean = new InAppPurchaseData(inAppPurchaseData); string purchaseToken = inAppPurchaseDataBean.PurchaseToken; ConsumePurchase(purchaseToken); Debug.Log("HMSP: recoverPurchases result> " + result.ReturnCode); } }).AddOnFailureListener((exception) => { Debug.Log("HMSP: Error on recoverPurchases" + exception.StackTrace); }); }