protected override void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data)

        {
            base.OnActivityResult(requestCode, resultCode, data);
            if (requestCode == Constants.REQ_CODE_BUY)
            {
                if (data == null)
                {
                    Log.Error(TAG, "data is null");
                    return;
                }

                PurchaseResultInfo purchaseIntentResult = Iap.GetIapClient(this).ParsePurchaseResultInfoFromIntent(data);
                switch (purchaseIntentResult.ReturnCode)
                {
                case OrderStatusCode.OrderStateCancel:
                    Toast.MakeText(this, "Order has been canceled!", ToastLength.Long).Show();
                    break;

                case OrderStatusCode.OrderStateFailed:
                    Toast.MakeText(this, GetString(Resource.String.pay_fail), ToastLength.Long).Show();
                    break;

                case OrderStatusCode.OrderStateSuccess:
                    Toast.MakeText(this, GetString(Resource.String.pay_success), ToastLength.Long).Show();
                    presenter.RefreshSubscription();
                    break;

                default:
                    break;
                }
                return;
            }
        }
        void CreateClient()
        {
            this.iapClient = Iap.GetIapClient();
            var moduleInitTask = iapClient.EnvReady;

            moduleInitTask.AddOnSuccessListener(ClientinitSuccess).AddOnFailureListener(ClientInitFailed);
        }
Example #3
0
        private void QueryIsReady()
        {
            Log.Info(TAG, "IsReady");
            IIapClient mClient    = Iap.GetIapClient(this);
            Task       isEnvReady = mClient.IsEnvReady();

            isEnvReady.AddOnSuccessListener(new ListenerImp()).AddOnFailureListener(new ListenerImp());
        }
Example #4
0
 protected override void OnCreate(Bundle savedInstanceState)
 {
     base.OnCreate(savedInstanceState);
     Xamarin.Essentials.Platform.Init(this, savedInstanceState);
     SetContentView(Resource.Layout.activity_non_consumption);
     mClient = Iap.GetIapClient(this);
     InitView();
     QueryPurchases(null);
 }
Example #5
0
        void CreateClient()
        {
            this.iapClient = Iap.GetIapClient();
            var moduleInitTask = iapClient.EnvReady;

            Debug.Log("UnityIapProvider - HuaweiStore iapClient is created!");

            moduleInitTask.AddOnSuccessListener(ClientinitSuccess).AddOnFailureListener(ClientInitFailed);
        }
        private void QueryHistoryInterface()
        {
            IIapClient        iapClient = Iap.GetIapClient(this);
            OwnedPurchasesReq req       = new OwnedPurchasesReq();

            req.PriceType         = IapClientPriceType.InAppConsumable;
            req.ContinuationToken = continuationToken;
            iapClient.ObtainOwnedPurchaseRecord(req).AddOnSuccessListener(new ObtainListenerImp(this)).AddOnFailureListener(new ObtainListenerImp(this));
        }
Example #7
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");
                }
            }
        });
    }
        private void QueryProducts()
        {
            Log.Info(TAG, "QueryProducts");
            List <String> productIdList = new List <String>();

            //Add the product ID that has been created in AppGallery console
            productIdList.Add("ProductCons1");

            ProductInfoReq req = new ProductInfoReq();

            req.PriceType  = IapClientPriceType.InAppConsumable;
            req.ProductIds = productIdList;

            Task task = Iap.GetIapClient(this).ObtainProductInfo(req);

            task.AddOnSuccessListener(new QueryProductListenerImp(this)).AddOnFailureListener(new QueryProductListenerImp(this));
        }
        public void CheckIapAvailability()
        {
            iapClient = Iap.GetIapClient();
            ITask <EnvReadyResult> task = iapClient.EnvReady;

            task.AddOnSuccessListener((result) =>
            {
                Debug.Log("HMSP: checkIapAvailabity SUCCESS");
                iapAvailable = true;
                OnCheckIapAvailabilitySuccess?.Invoke();
            }).AddOnFailureListener((exception) =>
            {
                Debug.Log("HMSP: Error on ObtainOwnedPurchases");
                iapClient    = null;
                iapAvailable = false;
                OnCheckIapAvailabilityFailure?.Invoke(exception);
            });
        }
Example #10
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);
                }
                );
            });
        }
 public SubscriptionPresenter(SubscriptionContract.View view)
 {
     SetView(view);
     mClient = Iap.GetIapClient(view.GetActivity());
 }