Esempio n. 1
0
 public void OnFailure(Java.Lang.Exception e)
 {
     Log.Info(TAG, "Onfailure");
     if (e.GetType() == typeof(IapApiException))
     {
         IapApiException apiException = (IapApiException)e;
         if (apiException.Status.StatusCode == OrderStatusCode.OrderHwidNotLogin)
         {
             if (apiException.Status.HasResolution)
             {
                 try
                 {
                     Log.Info(TAG, apiException.Status.StatusMessage);
                     apiException.Status.StartResolutionForResult(MainActivity.CurrentContext, Constants.REQ_CODE_LOGIN);
                 }
                 catch (Java.Lang.Exception exp)
                 {
                     Log.Error(TAG, exp.Message);
                 }
             }
         }
         else if (apiException.Status.StatusCode == OrderStatusCode.OrderAccountAreaNotSupported)
         {
             Toast.MakeText(MainActivity.CurrentContext, "This is unavailable in your country/region.", ToastLength.Long).Show();
         }
     }
 }
Esempio n. 2
0
        public static int handle(Activity activity, Java.Lang.Exception e)
        {
            if ((e.GetType() == typeof(IapApiException)))
            {
                IapApiException iapApiException = (IapApiException)e;
                int             StatusCode      = iapApiException.Status.StatusCode;
                Log.Debug("Error", "returnCode: " + StatusCode);
                switch (StatusCode)
                {
                case OrderStatusCode.OrderStateCancel:
                    Toast.MakeText(activity, "Order has been canceled!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderStateParamError:
                    Toast.MakeText(activity, "Order state param error!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderStateNetError:
                    Toast.MakeText(activity, "Order state net error!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderVrUninstallError:
                    Toast.MakeText(activity, "Order vr uninstall error!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderProductOwned:
                    Toast.MakeText(activity, "Product already owned error!", ToastLength.Short).Show();
                    return(OrderStatusCode.OrderProductOwned);

                case OrderStatusCode.OrderProductNotOwned:
                    Toast.MakeText(activity, "Product not owned error!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderProductConsumed:
                    Toast.MakeText(activity, "Product consumed error!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderAccountAreaNotSupported:
                    Toast.MakeText(activity, "Order account area not supported error!", ToastLength.Short).Show();
                    return(SOLVED);

                case OrderStatusCode.OrderNotAcceptAgreement:
                    Toast.MakeText(activity, "User does not agree the agreement", ToastLength.Short).Show();
                    return(SOLVED);

                default:
                    // handle other error scenarios
                    Toast.MakeText(activity, "Order unknown error!", ToastLength.Short).Show();
                    return(SOLVED);
                }
            }
            else
            {
                Toast.MakeText(activity, "external error", ToastLength.Short).Show();
                Log.Debug("Error", e.Message);
                return(SOLVED);
            }
        }
 public void OnFailure(Java.Lang.Exception e)
 {
     if (e.GetType() == typeof(IapApiException))
     {
         IapApiException apiException = (IapApiException)e;
         int             returnCode   = apiException.Status.StatusCode;
         Log.Error(TAG, "consumeOwnedPurchase fail, IapApiException returnCode: " + returnCode);
     }
     else
     {
         Log.Error(TAG, e.Message);
     }
 }
Esempio n. 4
0
    private void checkIapAvailabity()
    {
        iapClient = Iap.GetIapClient();

        ITask <EnvReadyResult> task = iapClient.EnvReady;

        task.AddOnSuccessListener((result) =>
        {
            Debug.Log("HMSP: checkIapAvailabity SUCCESS");
            InitIAP();
        }).AddOnFailureListener((exception) =>
        {
            Debug.Log("HMSP: Error on ObtainOwnedPurchases");

            if (IapApiExceptionUtils.IsIapApiException(exception))
            {
                IapApiException iapApiException = IapApiExceptionUtils.AsIapApiException((exception));


                Status status = iapApiException.Status;
                if (status.StatusCode == OrderStatusCode.ORDER_HWID_NOT_LOGIN)
                {
                    // User not logged in
                    if (status.HasResolution())
                    {
                        status.StartResolutionForResult((androidIntent) =>
                        {
                            Debug.Log("[HMS]: IAP login intent launched");
                            ITask <AuthHuaweiId> authTask = HuaweiIdAuthManager.ParseAuthResultFromIntent(androidIntent);

                            authTask.AddOnSuccessListener((result) =>
                            {
                                Debug.Log("[HMS]: IAP logged in user:"******"[HMS]: IAP user not logged:" + authException.Message);
                            });
                        }, (statusException) =>
                        {
                            Debug.Log("[HMS]: IAP login intent ERROR");
                        });
                    }
                }
                else if (status.StatusCode == OrderStatusCode.ORDER_ACCOUNT_AREA_NOT_SUPPORTED)
                {
                    // The current region does not support HUAWEI IAP.
                    Debug.Log("[HMS]: USer Area not supported by Huawei IAP");
                }
            }
        });
    }
Esempio n. 5
0
        public void CheckIapAvailability()
        {
            iapClient = Iap.GetIapClient();
            ITask <EnvReadyResult> task = iapClient.EnvReady;

            task.AddOnSuccessListener((result) =>
            {
                Debug.Log("[HMSIAPManager] checkIapAvailabity SUCCESS");
                iapAvailable = true;
                OnCheckIapAvailabilitySuccess?.Invoke();
                ObtainProductInfo(HMSIAPProductListSettings.Instance.GetProductIdentifiersByType(HMSIAPProductType.Consumable),
                                  HMSIAPProductListSettings.Instance.GetProductIdentifiersByType(HMSIAPProductType.NonConsumable),
                                  HMSIAPProductListSettings.Instance.GetProductIdentifiersByType(HMSIAPProductType.Subscription));
            }).AddOnFailureListener((exception) =>
            {
                Debug.LogError("[HMSIAPManager]: Error on EnvReady");
                IapApiException iapEx = exception.AsIapApiException();
                iapEx.Status.StartResolutionForResult
                (
                    (intent) =>
                {
                    Debug.Log("[HMSIAPManager]: Success on iapEx Resolution");
                    OnCheckIapAvailabilitySuccess?.Invoke();
                    ObtainProductInfo(HMSIAPProductListSettings.Instance.GetProductIdentifiersByType(HMSIAPProductType.Consumable),
                                      HMSIAPProductListSettings.Instance.GetProductIdentifiersByType(HMSIAPProductType.NonConsumable),
                                      HMSIAPProductListSettings.Instance.GetProductIdentifiersByType(HMSIAPProductType.Subscription));
                },
                    (ex) =>
                {
                    iapClient    = null;
                    iapAvailable = false;

                    Debug.LogError("[HMSIAPManager]: ERROR on StartResolutionForResult: " + ex.WrappedCauseMessage + " " + ex.WrappedExceptionMessage);
                    OnCheckIapAvailabilityFailure?.Invoke(exception);
                }
                );
            });
        }