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;
            }
        }
Example #2
0
 private void listPlans_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     textCarrier.Text = "";
     textEmp.Text     = "";
     textPlanNum.Text = "";
     if (listPlans.SelectedIndex >= 0)
     {
         textPlanNum.Text = list[listPlans.SelectedIndex * 2].ToString();
         try{
             Iap.ReadRecord(textPlanNum.Text);
             textCarrier.Text = Iap.ReadField(Iap.Carrier);
             textEmp.Text     = Iap.ReadField(Iap.Employer);
         }
         catch (ApplicationException ex) {
             MessageBox.Show(ex.Message);
             textCarrier.Text = "";
             textEmp.Text     = "";
             textPlanNum.Text = "";
             return;
         }
         finally{
             Iap.CloseDatabase();
         }
     }
 }
        void CreateClient()
        {
            this.iapClient = Iap.GetIapClient();
            var moduleInitTask = iapClient.EnvReady;

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

            isEnvReady.AddOnSuccessListener(new ListenerImp()).AddOnFailureListener(new ListenerImp());
        }
    public static string GetItemPrice(this StoreItemPack itemPack)
    {
#if UNITY_IOS
        var price = Iap.GetItemPrice(itemPack.SKU);
        return(string.IsNullOrEmpty(price) ? "USD " + (itemPack.USDPrice - 0.01f) : price);
#else
        return("$" + (itemPack.USDPrice - 0.01f));
#endif
    }
Example #6
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 #7
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 #9
0
        /// <summary>
        /// 从加密bin文件中获取升级数据包
        /// </summary>
        /// <param name="file">文件路径和文件名</param>
        private void GetPackageList(string file)
        {
            Iap iap = new Iap(file);

            this.sswSendList.Add(new SSW_Send(iap.GetSSWPackage()));

            for (int i = 0; i < iap.GetPackageNum(); i++)
            {
                this.uswSendList.Add(new USW_Send(iap.GetUSWPackage(i)));
            }

            this.qswSendList.Add(new QSW_Send(iap.GetQSWPackage()));
        }
Example #10
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 #13
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);
                }
                );
            });
        }
Example #14
0
 private void listEmployers_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     if (listEmployers.SelectedIndex == -1)
     {
         textCarrier.Text = "";
     }
     else
     {
         try{
             Iap.ReadRecord((string)listEmployers.SelectedItem);
         }
         catch (ApplicationException ex) {
             Iap.CloseDatabase();
             MessageBox.Show(ex.Message);
             textCarrier.Text = "";
             textEmp.Text     = "";
             return;
         }
         textCarrier.Text = Iap.ReadField(Iap.Carrier);
         textEmp.Text     = Iap.ReadField(Iap.Employer);
         Iap.CloseDatabase();
     }
 }
 public SubscriptionPresenter(SubscriptionContract.View view)
 {
     SetView(view);
     mClient = Iap.GetIapClient(view.GetActivity());
 }