private void ObtainProductInfo(IList <string> productIdNonConsumablesList, int priceType) { if (iapAvailable != true) { OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE); return; } ProductInfoReq productInfoReq = new ProductInfoReq { PriceType = priceType, ProductIds = productIdNonConsumablesList }; iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type) => { Debug.Log("[HMSPlugin]:" + type.ErrMsg + type.ReturnCode.ToString()); Debug.Log("[HMSPlugin]: {0=Consumable} {1=Non-Consumable} {2=Subscription}"); Debug.Log("[HMSPlugin]: Found " + type.ProductInfoList.Count + " type of " + priceType + " products"); OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> { type }); }).AddOnFailureListener((exception) => { Debug.Log("[HMSPlugin]: ERROR non Consumable ObtainInfo" + exception.Message); OnObtainProductInfoFailure?.Invoke(exception); }); }
public void ObtainProductSubscriptionInfo(IList <string> productIdSubscriptionList) { if (iapAvailable != true) { OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE); return; } ProductInfoReq productInfoReq = new ProductInfoReq { PriceType = 2, ProductIds = productIdSubscriptionList }; iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type2) => { Debug.Log("[HMSPlugin]:" + type2.ErrMsg + type2.ReturnCode.ToString()); Debug.Log("[HMSPlugin]: Found " + type2.ProductInfoList.Count + "consumable products"); OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> { type2 }); }).AddOnFailureListener((exception) => { Debug.Log("[HMSPlugin]: ERROR Consumable ObtainInfo" + exception.Message); OnObtainProductInfoFailure?.Invoke(exception); }); }
// TODO Obtain non-consumables too! public void ObtainProductInfo(IList <string> productIdConsumablesList = null) { if (iapAvailable != true) { OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE); return; } ProductInfoReq productInfoReq = new ProductInfoReq { PriceType = 0, ProductIds = productIdConsumablesList }; iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type0) => { Debug.Log("[HMSPlugin]:" + type0.ErrMsg + type0.ReturnCode.ToString()); Debug.Log("[HMSPlugin]: Found " + type0.ProductInfoList.Count + "consumable products"); productInfoReq = new ProductInfoReq { PriceType = 1, ProductIds = productIdConsumablesList }; iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type1) => { Debug.Log("[HMSPlugin]:" + type1.ErrMsg + type1.ReturnCode.ToString()); Debug.Log("[HMSPlugin]: Found " + type1.ProductInfoList.Count + "consumable products"); productInfoReq = new ProductInfoReq { PriceType = 0, ProductIds = productIdConsumablesList }; OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> { type0, type1 }); }).AddOnFailureListener((exception) => { Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message); OnObtainProductInfoFailure?.Invoke(exception); }); }).AddOnFailureListener((exception) => { Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message); OnObtainProductInfoFailure?.Invoke(exception); }); }
private void ObtainProductInfo(IList <string> productIdNonConsumablesList, PriceType priceType) { if (iapAvailable != true) { OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE); return; } ProductInfoReq productInfoReq = new ProductInfoReq { PriceType = priceType, ProductIds = productIdNonConsumablesList }; iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type) => { Debug.Log("[HMSIAPManager]:" + type.ErrMsg + type.ReturnCode.ToString()); Debug.Log("[HMSIAPManager]: {0=Consumable} {1=Non-Consumable} {2=Subscription}"); Debug.Log("[HMSIAPManager]: Found " + type.ProductInfoList.Count + " type of " + priceType.Value + " products"); foreach (var productInfo in type.ProductInfoList) { if (!productInfoList.Exists(c => c.ProductId == productInfo.ProductId)) { productInfoList.Add(productInfo); } Debug.Log("[HMSIAPManager]: ProductId: " + productInfo.ProductId + ", ProductName: " + productInfo.ProductName + ", Price: " + productInfo.Price); } OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> { type }); }).AddOnFailureListener((exception) => { Debug.LogError("[HMSIAPManager]: ObtainProductInfo failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage); OnObtainProductInfoFailure?.Invoke(exception); }); }