Пример #1
0
 public ConnectionErrorInstance(string connectionId, string reason, AutoyaStatus status, Action <string, int, string, AutoyaStatus> failed)
 {
     this.connectionId = connectionId;
     this.reason       = reason;
     this.failed       = failed;
     this.status       = status;
 }
Пример #2
0
        private void ReloadPurchasability()
        {
            purchaseState = PurchaseFeatureState.Loading;

            purchaseErrorStatus = new AutoyaStatus();

            PurchaseRouter.HttpRequestHeaderDelegate httpRequestHeaderDel = (p1, p2, p3, p4) =>
            {
                return(httpRequestHeaderDelegate(p1, p2, p3, p4));
            };

            PurchaseRouter.HttpResponseHandlingDelegate httpResponseHandlingDel = (p1, p2, p3, p4, p5, p6, p7) =>
            {
                Action <string, int, string, AutoyaStatus> p7dash = (q1, q2, q3, status) =>
                {
                    // set autoyaStatus error if exist.
                    if (status.HasError())
                    {
                        purchaseErrorStatus = status;
                    }

                    p7(q1, q2, q3);
                };

                httpResponseHandlingDelegate(
                    p1,
                    p2,
                    p3,
                    p4,
                    p5,
                    p6,
                    p7dash
                    );
            };

            _purchaseRouter = new PurchaseRouter(
                mainthreadDispatcher.Commit,
                productSourceData => OnLoadProductsResponse(productSourceData),
                productId => OnTicketRequest(productId),
                ticketData => OnTicketResponse(ticketData),
                () =>
            {
                purchaseState = PurchaseFeatureState.Ready;
                OnPurchaseReady();
            },
                (err, code, reason) =>
            {
                purchaseState = PurchaseFeatureState.ReadyFailed;

                var cor = OnPurchaseReadyFailed(err, code, reason, purchaseErrorStatus);
                mainthreadDispatcher.Commit(cor);
            },
                onPaidPurchaseDoneInBackground,
                httpRequestHeaderDel,
                httpResponseHandlingDel
                );
        }
Пример #3
0
        /**
         *              purchase item asynchronously.
         *
         *              string purchaseId: the id for this purchase. this param will back in done or failed handler.
         *              string productId: platform-shard product id string.
         *              Action<string> done: fire when purchase is done in succeessful. string is purchaseId.
         *              Action<string, PurchaseRouter.PurchaseError, string> failed: fire when purchase is failed. 1st string is purchaseId.
         */
        public static void Purchase(string purchaseId, string productId, Action <string> done, Action <string, ErrorCodes, string, AutoyaStatus> failed)
        {
            if (autoya == null)
            {
                Debug.LogWarning("not yet. 1");
                // var cor = new AssetBundleLoadErrorInstance(assetName, "Autoya is null.", loadFailed).Coroutine();
                // autoya.mainthreadDispatcher.Commit(cor);
                return;
            }

            if (!Autoya.Auth_IsAuthenticated())
            {
                Debug.LogWarning("not yet. 2");
                // var cor = new AssetBundleLoadErrorInstance(assetName, "not authenticated.", loadFailed).Coroutine();
                // autoya.mainthreadDispatcher.Commit(cor);
                return;
            }

            if (autoya.purchaseState != PurchaseFeatureState.Ready)
            {
                Debug.LogWarning("not yet. 3");
                return;
            }

            if (!autoya._purchaseRouter.IsPurchaseReady())
            {
                Debug.LogWarning("not yet. 4");
                return;
            }

            purchaseErrorStatus = new AutoyaStatus();

            Action <string, PurchaseRouter.PurchaseError, int, string> _failed = (p1, p2, p3, p4) =>
            {
                failed(p1, new ErrorCodes(p2, p3), p4, purchaseErrorStatus);
            };

            autoya.mainthreadDispatcher.Commit(
                autoya._purchaseRouter.PurchaseAsync(purchaseId, productId, done, _failed)
                );
        }
Пример #4
0
 /**
  *      fire when failed to ready the purchase feature.
  *      Autoya already retried 3 times.
  *
  *      e,g, show dialog to player. for example "reloading purchase feature... please wait a moment" or other message of error.
  *      this err parameter includes "player can not available purchase feature" and other many situations are exists.
  *      see Purchase.PurchaseRouter.PurchaseError enum.
  *
  *      then, you can retry with Purchase_AttemptReady() method.
  *      when success, OnPurchaseReady will be called.
  */
 private void OnPurchaseReadyFailed(Purchase.PurchaseRouter.PurchaseError err, string reason, AutoyaStatus autoyaStatus)
 {
     // do something if need.
 }
Пример #5
0
 /**
  *      fire when failed to ready the purchase feature.
  *
  *      offline, server returned error, or failed to ready IAPFeature.
  *
  *      e,g, show dialog to player. for example "reloading purchase feature... please wait a moment" or other message of error.
  *              this err parameter includes "player can not available purchase feature".
  *
  *              see Purchase.PurchaseRouter.PurchaseReadyError enum.
  *
  *      then, you can retry with Purchase_AttemptReady() method.
  *      when success, OnPurchaseReady will be called.
  */
 private IEnumerator OnPurchaseReadyFailed(Purchase.PurchaseRouter.PurchaseReadyError err, int code, string reason, AutoyaStatus status)
 {
     // do something if need.
     yield break;
 }