Esempio n. 1
0
    void RecieveFromJava(string message)
    {
                #if UNITY_ANDROID
        Debug.Log("Received from java message: " + message);

        if (message != "Fail")
        {
            BundlePurchaseRequest bundlePurchaseRequest = new BundlePurchaseRequest();
            bundlePurchaseRequest.BundleID     = currentBundleID;
            bundlePurchaseRequest.UserID       = CloudGoods.user.userID.ToString();
            bundlePurchaseRequest.ReceiptToken = message;

            //TODO implement platform check for platform premium currency bundle purchase
            bundlePurchaseRequest.PaymentPlatform = 3;

            string bundleJsonString = JsonConvert.SerializeObject(bundlePurchaseRequest);

            CloudGoods.PurchaseCreditBundles(bundleJsonString, OnReceivedPurchaseResponse);
        }
        else
        {
            PurchasePremiumCurrencyBundleResponse response = new PurchasePremiumCurrencyBundleResponse();
            response.StatusCode = 0;
            response.Message    = message;

            OnPurchaseErrorEvent(response);
        }
#endif
    }
    void SendReceiptTokenForVerification(string data, int platform)
    {
        BundlePurchaseRequest bundlePurchaseRequest = new BundlePurchaseRequest();

        bundlePurchaseRequest.BundleID        = currentBundleID;
        bundlePurchaseRequest.UserID          = CloudGoods.user.userID.ToString();
        bundlePurchaseRequest.ReceiptToken    = data;
        bundlePurchaseRequest.PaymentPlatform = platform;
        string bundleJsonString = JsonMapper.ToJson(bundlePurchaseRequest);

        Debug.Log("Sending bundle purchase: " + bundleJsonString);

        CloudGoods.PurchaseCreditBundles(bundleJsonString, OnReceivedPurchaseResponse);
    }
    public void OnReceivedFacebookCurrencyPurchase(string data)
    {
        Debug.Log("data: " + data);
        JsonMapper.ToObject(data);

        Newtonsoft.Json.Linq.JToken parsedData = Newtonsoft.Json.Linq.JToken.Parse(data);

        if (parsedData["error_message"] != null)
        {
            PurchasePremiumCurrencyBundleResponse response = new PurchasePremiumCurrencyBundleResponse();
            response.StatusCode = 0;
            response.Message    = parsedData["error_message"].ToString();

            if (OnPurchaseErrorEvent != null)
            {
                OnPurchaseErrorEvent(response);
            }
            return;
        }

        Debug.Log("parsedData: " + parsedData.ToString());

        BundlePurchaseRequest bundlePurchaseRequest = new BundlePurchaseRequest();

        bundlePurchaseRequest.BundleID     = currentBundleID;
        bundlePurchaseRequest.UserID       = CloudGoods.user.userID.ToString();
        bundlePurchaseRequest.ReceiptToken = parsedData["payment_id"].ToString();

        //TODO implement platform check for platform premium currency bundle purchase
        bundlePurchaseRequest.PaymentPlatform = 1;

        string bundleJsonString = JsonConvert.SerializeObject(bundlePurchaseRequest);

        CloudGoods.PurchaseCreditBundles(bundleJsonString, OnReceivedPurchaseResponse);

        //if (RecievedPurchaseResponse != null)
        //    RecievedPurchaseResponse(data);
    }