Esempio n. 1
0
    /// <summary>
    /// 구매 Buys the product identifier.
    /// </summary>
    /// <param name="productId">The product identifier.</param>
    public void BuyProductID(DEF.IAPData _itemInfo, System.Action <string, GooglePlayReceipt, AppleInAppPurchaseReceipt> Complete)
    {
#if UNITY_EDITOR
        if (Complete != null)
        {
            Complete("failed", null, null);
            return;
        }
#endif

        // If Purchasing has been initialized ...
        if (IsInitialized())
        {
            iapData = _itemInfo;
            //strProductId = productId;

            _onComplete = Complete;
            // ... look up the Product reference with the general product identifier and the Purchasing
            // system's products collection.
            Product product = m_StoreController.products.WithID(iapData.id.ToString());

            // If the look up found a product for this device's store and that product is ready to be sold ...
            if (product != null && product.availableToPurchase)
            {
                Debug.Log(string.Format("Purchasing product asychronously: '{0}'", product.definition.id));
                // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed
                // asynchronously.
                m_StoreController.InitiatePurchase(product);
            }
            // Otherwise ...
            else
            {
                if (_onComplete != null)
                {
                    _onComplete("failed", null, null);
                }
                // ... report the product look-up failure situation
                Debug.Log("Buy ProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
                UI.I.ShowMsgBox("Buy ProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
            }
        }
        // Otherwise ...
        else
        {
            if (_onComplete != null)
            {
                _onComplete("failed", null, null);
            }
            // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or
            // retrying initiailization.
            Debug.Log("Buy ProductID FAIL. Not initialized.");
            UI.I.ShowMsgBox("Buy ProductID FAIL. Not initialized.");
        }
    }
Esempio n. 2
0
    /// <summary>
    /// Appses the flyer event.
    /// </summary>
    public void AppsFlyerEvent_Purchase(DEF.IAPData iapInfo)
    {
        Dictionary <string, string> eventValue = new Dictionary <string, string>();

        bool bFirstPurchase = USER.I._PKUserInfo.data.total_purchase == 0 ? true : false;

        eventValue.Add(AFInAppEvents.CONTENT_ID, iapInfo.id.ToString());
        eventValue.Add(AFInAppEvents.FIRST_PAYDAY_IN_3DAYS, USER.I.bFirstPayDayin3Day.ToString());
        eventValue.Add(AFInAppEvents.FIRST_PURCHASE_ITEM, bFirstPurchase.ToString());
        eventValue.Add(AFInAppEvents.PURCHASE_ACCUMULATE_ACCOUNT, USER.I._PKUserInfo.data.total_purchase.ToString());
        eventValue.Add(AFInAppEvents.PURCHASE_COINS, iapInfo.coins.ToString());
        eventValue.Add(AFInAppEvents.PURCHASE_COUNT, "1");
        eventValue.Add(AFInAppEvents.CURRENCY, "USD");
        eventValue.Add(AFInAppEvents.REVENUE, iapInfo.price.ToString());

        AppsFlyer.trackRichEvent(AFInAppEvents.PURCHASE, eventValue);

        // 유저 업데이트 패킷을 보낼필요없이 토탈구매만 갱신처리
        // 첫구매 팝업 예외처리 플러그로도 이용하고 있다.
        USER.I._PKUserInfo.data.total_purchase += (long)iapInfo.price;
    }