Ejemplo n.º 1
0
 public void OnIabQueryInventoryFinished(IabResult result, IabInventory inventory)
 {
     if (result.Response == AppMarketHelper.BILLING_RESPONSE_RESULT_OK)
     {
         List <IabPurchase> purchase_list = inventory.getAllPurchases();
         DataManagerAlarm.Instance.purchased_list.Clear();
         foreach (IabPurchase purchase in purchase_list)
         {
             DataManagerAlarm.Instance.purchased_list.Add(purchase.Sku);
             //Debug.LogError( string.Format( "productId:{0}" ,purchase.productId ));
         }
     }
     return;
 }
Ejemplo n.º 2
0
    public void RakutenAppMarketHelperRawCallback(string packet)
    {
        Debug.LogError("AppMarketHelper.RakutenAppMarketHelperRawCallback " + packet);

        if (StoredCallback == null)
        {
            DebugLogger.Log("Callback is not ready.");
            return;
        }

        if (CallbackPacketCnt == 0)
        {
            string[] splitted = packet.Split(new char[] { ':' }, 2);
            CallbackSpec      = splitted[0];
            CallbackMessage   = "";
            CallbackPacketIdx = 0;
            CallbackPacketCnt = int.Parse(splitted[1]);

            DebugLogger.Log("CallbackSpec: " + CallbackSpec + ", CallbackPacketCnt:" + CallbackPacketCnt);

            return;
        }
        CallbackMessage += packet;

        if (++CallbackPacketIdx < CallbackPacketCnt)
        {
            return;
        }

        // DebugLogger.Log("CallbackMessage: " + CallbackMessage);

        CallbackPacketCnt = 0;
        JsonData paramsJson = JsonMapper.ToObject(CallbackMessage);

        switch (CallbackSpec)
        {
        case ACTION_SET_UP: {
            StoredCallback.OnAppMarketSetupFinished();
            break;
        }

        case ACTION_INIT_BILLING: {
            IabResult param1 = new IabResult(paramsJson[0]);
            StoredCallback.OnInitBIllingFinished(param1);
            break;
        }

        case ACTION_INIT_LICENSE: {
            StoredCallback.OnInitLicenseFinished();
            break;
        }

        case ACTION_QUERY_INVENTORY: {
            IabResult    param1 = new IabResult(paramsJson[0]);
            IabInventory param2 = null;
            if (1 < paramsJson.Count)
            {
                param2 = new IabInventory(paramsJson[1]);
            }
            StoredCallback.OnIabQueryInventoryFinished(param1, param2);
            break;
        }

        case ACTION_LAUNCH_PURCHASE_FLOW: {
            IabResult   param1 = new IabResult(paramsJson[0]);
            IabPurchase param2 = null;
            if (1 < paramsJson.Count)
            {
                param2 = new IabPurchase(paramsJson[1]);
            }
            StoredCallback.OnIabPurchaseFinished(param1, param2);
            break;
        }

        case ACTION_LAUNCH_SUBSCRIPTION_PURCHASE_FLOW: {
            IabResult   param1 = new IabResult(paramsJson[0]);
            IabPurchase param2 = null;
            if (1 < paramsJson.Count)
            {
                param2 = new IabPurchase(paramsJson[1]);
            }
            StoredCallback.OnIabSubscriptionPurchaseFinished(param1, param2);
            break;
        }

        case ACTION_CONSUME: {
            IabResult   param1 = new IabResult(paramsJson[0]);
            IabPurchase param2 = null;
            if (1 < paramsJson.Count)
            {
                param2 = new IabPurchase(paramsJson[1]);
            }
            StoredCallback.OnIabConsumeFinished(param1, param2);
            break;
        }

        case ACTION_QUERY_SKU_DETAILS: {
            IabResult param1 = new IabResult(paramsJson[0]);
            Dictionary <string, IabSkuDetails> param2 = new Dictionary <string, IabSkuDetails>();
            if (1 < paramsJson.Count)
            {
                foreach (string k in paramsJson[1].Keys)
                {
                    param2.Add(k, new IabSkuDetails(paramsJson[1][k]["ItemType"].ToString(), paramsJson[1][k]));
                }
            }
            StoredCallback.OnIabQuerySkuDetailsFinished(param1, param2);
            break;
        }

        case ACTION_CHECK_LICENSE:
        {
            bool param1 = (bool)paramsJson[0];
            bool param2 = (bool)paramsJson[1];
            StoredCallback.OnLicenseCheckFinished(param1, param2);
            break;
        }

        case ACTION_ERROR: {
            string param1 = paramsJson[0].ToString();
            string param2 = paramsJson[1].ToString();
            StoredCallback.OnAppMarketError(param1, param2);
            break;
        }
        }
    }