public void RemoveRcoveryItemData(NIAPPurchase ConsumeItem)
    {
        if (this.m_RecoveryItem == null)
        {
            return;
        }
        this.m_bRecovery = false;
        if (this.m_RecoveryItem != null)
        {
            this.m_RecoveryItem = null;
        }
        this.m_PurchaseList.Remove(ConsumeItem.getProductCode());
        if (NrTSingleton <GameGuideManager> .Instance.ExecuteGuide)
        {
            GameGuideDlg gameGuideDlg = NrTSingleton <FormsManager> .Instance.GetForm(G_ID.GAMEGUIDE_DLG) as GameGuideDlg;

            if (gameGuideDlg != null)
            {
                if (NrTSingleton <GameGuideManager> .Instance.ContinueCheck(GameGuideType.PURCHASE_RESTORE))
                {
                    gameGuideDlg.SetTalkText();
                }
                else
                {
                    gameGuideDlg.ClickClose(null);
                }
            }
        }
        else
        {
            NrTSingleton <GameGuideManager> .Instance.RemoveGuide(GameGuideType.PURCHASE_RESTORE);
        }
    }
    public void RecoveryItem()
    {
        this.m_RecoveryItem = this.m_PushPurchaseList.Pop();
        if (this.m_RecoveryItem != null)
        {
            this.Receipt.Remove(0, this.Receipt.Length);
            string arg = string.Empty;
            this.NStorePurchase(this.m_RecoveryItem.getOriginalPurchaseAsJsonText().dictionaryFromJson(), ref this.strProductID);
            arg = this.m_RecoveryItem.getSignature();
            if (TsPlatform.IsBand)
            {
                this.Receipt.Append(string.Format("MarketType={0}&Signature={1}&SignedData={2}", "bandnaver", arg, this.m_RecoveryItem.getOriginalPurchaseAsJsonText()));
            }
            else
            {
                this.Receipt.Append(string.Format("MarketType={0}&Signature={1}&SignedData={2}", "naver", arg, this.m_RecoveryItem.getOriginalPurchaseAsJsonText()));
            }
            NrMyCharInfo myCharInfo = NrTSingleton <NkCharManager> .Instance.GetMyCharInfo();

            if (myCharInfo != null)
            {
                GS_BILLINGCHECK_REQ gS_BILLINGCHECK_REQ = new GS_BILLINGCHECK_REQ();
                gS_BILLINGCHECK_REQ.i64ItemMallIndex = NrTSingleton <ItemMallItemManager> .Instance.GetItemIndex(this.strProductID);

                TKString.StringChar(this.Receipt.ToString(), ref gS_BILLINGCHECK_REQ.Receipt);
                SendPacket.GetInstance().SendObject(eGAME_PACKET_ID.GS_BILLINGCHECK_REQ, gS_BILLINGCHECK_REQ);
                PlayerPrefs.SetString(NrPrefsKey.SHOP_PRODUCT_ID, gS_BILLINGCHECK_REQ.i64ItemMallIndex.ToString());
                PlayerPrefs.SetString(NrPrefsKey.SHOP_RECEIPT, this.Receipt.ToString());
                if (TsPlatform.IsBand)
                {
                    PlayerPrefs.SetString(NrPrefsKey.BAND_RECEIPT, this.m_RecoveryItem.getOriginalPurchaseAsJsonText());
                }
                TsPlatform.FileLog(string.Format("TStorePurchaseComplete\nReceipt ={0} ProductID = {1} ItemMallIdex = {2}", this.Receipt, this.strProductID, gS_BILLINGCHECK_REQ.i64ItemMallIndex));
                TsLog.LogWarning("Send BillingCheck ProductID = {0} ItemMallIdex = {1}", new object[]
                {
                    this.strProductID,
                    gS_BILLINGCHECK_REQ.i64ItemMallIndex
                });
                this.Receipt.Remove(0, this.Receipt.Length);
            }
            GS_BILLING_ITEM_RECODE_REQ gS_BILLING_ITEM_RECODE_REQ = new GS_BILLING_ITEM_RECODE_REQ();
            gS_BILLING_ITEM_RECODE_REQ.i8Type           = 1;
            gS_BILLING_ITEM_RECODE_REQ.i8Result         = 0;
            gS_BILLING_ITEM_RECODE_REQ.i64ItemMallIndex = NrTSingleton <ItemMallItemManager> .Instance.GetItemIndex(this.strProductID);

            SendPacket.GetInstance().SendObject(eGAME_PACKET_ID.GS_BILLING_ITEM_RECODE_REQ, gS_BILLING_ITEM_RECODE_REQ);
            NrTSingleton <NrMainSystem> .Instance.m_bIsBilling = false;
        }
        else
        {
            this.m_bRecovery = false;
        }
    }
    public void returnSuccess(string result)
    {
        JSONNode jSONNode = JSON.Parse(result);
        string   text     = jSONNode[NIAPConstant.invokeMethod];

        Debug.Log("success! invokeMethod : " + text + " result : " + result);
        if (string.Equals(text, NIAPConstant.InvokeMethod.getProductDetails))
        {
            if (this.getProductDetailsSuccessEvent != null)
            {
                this.getProductDetailsSuccessEvent(NIAPResult.Build(result));
            }
            this.getProductDetailsSuccessEvent = null;
        }
        else if (string.Equals(text, NIAPConstant.InvokeMethod.requestPayment))
        {
            if (this.requestPaymentSuccessEvent != null)
            {
                this.requestPaymentSuccessEvent(NIAPPurchase.Build(result));
            }
            this.requestPaymentSuccessEvent  = null;
            this.requestPaymentCanceledEvent = null;
        }
        else if (string.Equals(text, NIAPConstant.InvokeMethod.requestConsume))
        {
            if (this.consumeSuccessEvent != null)
            {
                this.consumeSuccessEvent(NIAPResult.Build(result));
            }
            this.consumeSuccessEvent = null;
        }
        else if (string.Equals(text, NIAPConstant.InvokeMethod.getPurchases))
        {
            if (this.getPurchasesSuccessEvent != null)
            {
                this.getPurchasesSuccessEvent(NIAPResult.Build(result));
            }
            this.getPurchasesSuccessEvent = null;
        }
        else if (string.Equals(text, NIAPConstant.InvokeMethod.getSinglePurchase))
        {
            if (this.getSinglePurchaseSuccessEvent != null)
            {
                this.getSinglePurchaseSuccessEvent(NIAPPurchase.Build(result));
            }
            this.getSinglePurchaseSuccessEvent = null;
        }
    }
    public void Consume()
    {
        NIAPPurchase pItem = null;

        if (this.m_bRecovery)
        {
            pItem = this.m_RecoveryItem;
        }
        else
        {
            pItem = this.m_pResult;
        }
        if (pItem != null)
        {
            if (pItem.getOriginalPurchaseAsJsonText() != null && pItem.getSignature() != null)
            {
                NIAPNativeExtension.Instance.requestConsume(pItem.getOriginalPurchaseAsJsonText(), pItem.getSignature(), delegate(NIAPResult niapResult)
                {
                    this.RemoveRcoveryItemData(pItem);
                }, delegate(NIAPResultError error)
                {
                    Debug.Log("consumePurchaseFailedEvent: " + error);
                    BillingManager_NStore component = BillingManager_NStore.Instance.GetComponent <BillingManager_NStore>();
                    if (component != null && component.m_RecoveryItem != null)
                    {
                        GS_BILLING_ITEM_RECODE_REQ gS_BILLING_ITEM_RECODE_REQ = new GS_BILLING_ITEM_RECODE_REQ();
                        gS_BILLING_ITEM_RECODE_REQ.i8Type           = 2;
                        gS_BILLING_ITEM_RECODE_REQ.i8Result         = 1;
                        gS_BILLING_ITEM_RECODE_REQ.i64ItemMallIndex = NrTSingleton <ItemMallItemManager> .Instance.GetItemIndex(pItem.getProductCode());
                        NrTSingleton <ItemMallItemManager> .Instance.RecodeErrorMessage(ref gS_BILLING_ITEM_RECODE_REQ, string.Format("requestConsume error code : {0} , error message : {1}", error.getCode(), error.getMessage()));
                        SendPacket.GetInstance().SendObject(eGAME_PACKET_ID.GS_BILLING_ITEM_RECODE_REQ, gS_BILLING_ITEM_RECODE_REQ);
                    }
                    this.RemoveRcoveryItemData(pItem);
                    if (!this.m_ConsumeFailedList.Contains(pItem))
                    {
                        this.m_ConsumeFailedList.Add(pItem);
                    }
                });
            }
        }
        else if (pItem == null)
        {
            TsLog.LogError("pItem == NULL", new object[0]);
        }
    }
 public void CheckRestoreItem()
 {
     this.m_PurchaseList.Clear();
     this.m_PushPurchaseList.Clear();
     NIAPNativeExtension.Instance.getPurchases(delegate(NIAPResult result)
     {
         string json = string.Empty;
         json        = result.getOrignalString();
         Dictionary <string, object> dictionary = json.dictionaryFromJson();
         if (dictionary != null && dictionary.ContainsKey("result"))
         {
             List <object> list  = dictionary["result"] as List <object>;
             List <object> list2 = dictionary["signature"] as List <object>;
             for (int i = 0; i < list.Count; i++)
             {
                 string json2 = (string)list[i];
                 Dictionary <string, object> dictionary2 = json2.dictionaryFromJson();
                 NIAPPurchase nIAPPurchase = new NIAPPurchase(dictionary2["paymentSeq"].ToString(), dictionary2["purchaseToken"].ToString(), dictionary2["purchaseType"].ToString(), dictionary2["environment"].ToString(), dictionary2["packageName"].ToString(), dictionary2["appName"].ToString(), dictionary2["productCode"].ToString(), dictionary2["paymentTime"].ToString(), dictionary2["developerPayload"].ToString(), dictionary2["nonce"].ToString(), (string)list2[i], (string)list[i]);
                 if (nIAPPurchase != null && !string.IsNullOrEmpty(nIAPPurchase.getDeveloperPayload()) && !nIAPPurchase.getDeveloperPayload().Contains("extra"))
                 {
                     this.m_PurchaseList.Add(dictionary2["productCode"].ToString(), nIAPPurchase);
                 }
             }
             foreach (NIAPPurchase current in this.m_PurchaseList.Values)
             {
                 if (!this.m_ConsumeFailedList.Contains(current))
                 {
                     this.m_PushPurchaseList.Push(current);
                 }
             }
             if (this.m_PurchaseList.Count > 0)
             {
                 NrTSingleton <GameGuideManager> .Instance.CheckGameGuide(GameGuideType.PURCHASE_RESTORE);
             }
         }
     }, delegate(NIAPResultError error)
     {
         TsLog.LogError("getPurchases error code : {0} , error message :{1} ", new object[]
         {
             error.getCode(),
             error.getMessage()
         });
     });
 }