コード例 #1
0
ファイル: InAppManager.cs プロジェクト: robin1392/robin
 public void PlayStorePointPayment(PurchaseEventArgs args, GameBaseShopProtocol.ReceiveShopPurchaseAckDelegate callback)
 {
     if (inappViewLockCallback != null)
     {
         inappViewLockCallback();
     }
     this.buyCallback = callback;
     SendPostReceipt(args);
 }
コード例 #2
0
ファイル: InAppManager.cs プロジェクト: robin1392/robin
        private void ResultPurchaseSuccessed(PurchaseEventArgs args)
        {
            string payload = null;

#if UNITY_ANDROID
            payload = GetPayload(args).ToString();
#elif UNITY_IOS
            payload = args.purchasedProduct.receipt.ToString();
#endif


            if (isLog)
            {
                Debug.Log(string.Format("Percent [IAP] Purchase Successed: Product: {0}", args.purchasedProduct.definition.id));
            }

            isPurchaseInProgress = false;

            if (buyCallback == null && restoreCallback == null)
            {
                // start auto restore
            }

            if (buyCallback != null)
            {
                NetworkManager.session.ShopTemplate.ShopPurchaseReq(NetworkManager.session.HttpClient, shopId, shopProductId, payload, buyCallback);
            }
            buyCallback = null;

            if (restoreCallback != null)
            {
                NetworkManager.session.ShopTemplate.ShopPurchaseReq(NetworkManager.session.HttpClient, shopId, shopProductId, payload, restoreCallback);
            }

            if (inappViewUnLockCallback != null)
            {
                inappViewUnLockCallback();
            }

            if (args != null)
            {
                storeController.ConfirmPendingPurchase(args.purchasedProduct);
            }
        }
コード例 #3
0
ファイル: InAppManager.cs プロジェクト: robin1392/robin
        public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
        {
            if (isLog)
            {
                Debug.Log(string.Format("Percent [IAP] OnPurchaseFailed: FAIL. Product: {0}, PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
            }

            isPurchaseInProgress = false;

            if (buyCallback != null)
            {
                buyCallback(GameBaseShopErrorCode.PurchaseFailed, shopId, null, null, null, null, null);
            }
            buyCallback = null;
            if (inappViewUnLockCallback != null)
            {
                inappViewUnLockCallback();
            }
        }
コード例 #4
0
ファイル: InAppManager.cs プロジェクト: robin1392/robin
        private void ResultPurchaseFailed()
        {
            isPurchaseInProgress = false;

            if (buyCallback != null)
            {
                buyCallback(GameBaseShopErrorCode.PurchaseFailed, shopId, null, null, null, null, null);
            }
            buyCallback = null;

            if (restoreCallback != null)
            {
                restoreCallback(GameBaseShopErrorCode.PurchaseFailed, shopId, null, null, null, null, null);
            }
            restoreCallback = null;

            if (inappViewUnLockCallback != null)
            {
                inappViewUnLockCallback();
            }
        }
コード例 #5
0
ファイル: InAppManager.cs プロジェクト: robin1392/robin
        // 리스토어 (구매 상품 재구매)
        public void RestorePurchase(GameBaseShopProtocol.ReceiveShopPurchaseAckDelegate callback)
        {
            if (inappViewLockCallback != null)
            {
                inappViewLockCallback();
            }

            restoreCallback = callback;

            if (!GetInitialized())
            {
                if (isLog)
                {
                    Debug.Log("Percent [IAP] RestorePurchases FAIL. Not initialized.");
                }

                ResultPurchaseFailed();
                if (restoreCallback != null)
                {
                    restoreCallback(GameBaseShopErrorCode.PurchaseInitError, shopId, null, null, null, null, null);
                }
                if (inappViewUnLockCallback != null)
                {
                    inappViewUnLockCallback();
                }
                return;
            }

            if (Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.OSXPlayer)
            {
                if (isLog)
                {
                    Debug.Log("Percent [IAP] RestorePurchases started ...");
                }

                var apple = extensionProvider.GetExtension <IAppleExtensions>();

                apple.RestoreTransactions
                (
                    (result) => { if (isLog)
                                  {
                                      Debug.Log("Percent [IAP] RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore.");
                                  }
                    }
                );
            }
            else
            {
                if (isLog)
                {
                    Debug.Log("Percent [IAP] RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
                }

                ResultPurchaseFailed();
                if (restoreCallback != null)
                {
                    restoreCallback(GameBaseShopErrorCode.PurchaseNotSupportOS, shopId, null, null, null, null, null);
                }
                if (inappViewUnLockCallback != null)
                {
                    inappViewUnLockCallback();
                }
            }
        }
コード例 #6
0
ファイル: InAppManager.cs プロジェクト: robin1392/robin
        //인앱구매 시작
        public void BuyProductID(string productId, string playerGuid, int shopId, int shopProductId, GameBaseShopProtocol.ReceiveShopPurchaseAckDelegate callback)
        {
            this.playerGuid    = playerGuid;
            this.shopId        = shopId;
            this.shopProductId = shopProductId;

            if (buyCallback != null || isPurchaseInProgress == true)
            {
                // 이미 구매가 진행중
                if (isLog)
                {
                    Debug.Log("Percent [IAP] Please wait, purchase in progress");
                }
                if (callback != null)
                {
                    callback(GameBaseShopErrorCode.PurchaseAlreadyBuyProcess, this.shopId, null, null, null, null, null);
                }
                return;
            }

            if (inappViewLockCallback != null)
            {
                inappViewLockCallback();
            }

            isPurchaseInProgress = true;

            buyCallback     = null;
            restoreCallback = null;

            buyCallback = callback;

            try
            {
                if (GetInitialized())
                {
                    Product p = storeController.products.WithID(productId);

                    if (p != null && p.availableToPurchase)
                    {
                        // 구매 진행
                        if (isLog)
                        {
                            Debug.Log(string.Format("Percent [IAP] Purchasing product asychronously: '{0}'", p.definition.id));
                        }

                        storeController.InitiatePurchase(p);
                    }
                    else
                    {
                        // 식별 불가 상품
                        if (isLog)
                        {
                            Debug.Log("Percent [IAP] BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                        }

                        if (buyCallback != null)
                        {
                            buyCallback(GameBaseShopErrorCode.PurchaseAlreadyBuyProcess, this.shopId, null, null, null, null, null);
                        }
                        buyCallback = null;
                        ResultPurchaseFailed();
                        if (inappViewUnLockCallback != null)
                        {
                            inappViewUnLockCallback();
                        }
                    }
                }
                else
                {
                    // 초기화 불가능, 스토어 로그인을 체크하거나 인터넷 체크
                    if (isLog)
                    {
                        Debug.Log("Percent [IAP] BuyProductID FAIL. Not initialized.");
                    }

                    if (buyCallback != null)
                    {
                        buyCallback(GameBaseShopErrorCode.PurchaseAlreadyBuyProcess, this.shopId, null, null, null, null, null);
                    }
                    buyCallback = null;
                    ResultPurchaseFailed();
                    if (inappViewUnLockCallback != null)
                    {
                        inappViewUnLockCallback();
                    }
                }
            }
            catch (Exception e)
            {
                //코드로직 충돌
                if (isLog)
                {
                    Debug.Log("Percent [IAP] BuyProductID: FAIL. Exception during purchase. " + e);
                }

                if (buyCallback != null)
                {
                    buyCallback(GameBaseShopErrorCode.PurchaseAlreadyBuyProcess, this.shopId, null, null, null, null, null);
                }
                buyCallback = null;
                ResultPurchaseFailed();
                if (inappViewUnLockCallback != null)
                {
                    inappViewUnLockCallback();
                }
            }
        }