Request() public méthode

public Request ( string pUrl, object>.Dictionary pDataDic, Action onReturnRes ) : IEnumerator
pUrl string
pDataDic object>.Dictionary
onReturnRes Action
Résultat IEnumerator
Exemple #1
0
        public WWW POST(int type, string url, Dictionary <string, object> post)
        {
//			WWWForm form = new WWWForm();
//			StringBuilder sb = new StringBuilder ();
            if (!post.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && !post.ContainsKey("project") && !post.ContainsKey("access_data") && baseParams != null)
            {
                foreach (KeyValuePair <string, object> kv in baseParams)
                {
                    post.Add(kv.Key, kv.Value);                     //.Add (XsollaApiConst.ACCESS_TOKEN, _accessToken);
                }
                if (!post.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && !baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN) && (_accessToken != ""))
                {
                    post.Add(XsollaApiConst.ACCESS_TOKEN, _accessToken);
                }
            }
            if (type == DIRECTPAYMENT_STATUS)
            {
                TransactionHelper.SaveRequest(post);
            }
            if (!post.ContainsKey("alternative_platform"))
            {
                post.Add("alternative_platform", "unity/" + SDK_VERSION);
            }

//			foreach(KeyValuePair<string,object> post_arg in post)
//			{
//				string argValue = post_arg.Value != null ? post_arg.Value.ToString() : "";
//				sb.Append(post_arg.Key).Append("=").Append(argValue).Append("&");
//				form.AddField(post_arg.Key, argValue);
//
//			}

            if (httpreq == null)
            {
                httpreq = GameObject.Find(HttpTlsRequest.loaderGameObjName).GetComponent <HttpTlsRequest>();
            }

            StartCoroutine(httpreq.Request(url, post, (value) => ProcessingRequestResult(type, value, post)));

//			Debug.Log (url);
//			Debug.Log (sb.ToString());
//			WWW www = new WWW(url, form);
//			StartCoroutine(WaitForRequest(type, www, post));
            return(null);
        }
        public void CreatePaymentForm()
        {
            XsollaPaystationController formController = GetPaystationController();

            formController.OkHandler    += (status) => { Debug.Log("OkHandler 1 " + status); };
            formController.ErrorHandler += (error) => { Debug.Log("ErrorHandler 2 " + error); };


            XsollaJsonGenerator generator = new XsollaJsonGenerator("user_1", 14004);             //test 15764

            generator.user.name         = "John Smith";
            generator.user.email        = "*****@*****.**";
            generator.user.country      = "US";
            generator.settings.currency = "USD";
            generator.settings.languge  = "en";
            string request = generator.GetPrepared();

            // Prepare args
            Dictionary <string, object> dataArgs = new Dictionary <string, object>();

            dataArgs.Add("data", request);
            XsollaPaystation.AddHttpRequestObj();
            // Get object to request
            HttpTlsRequest httpreq = GameObject.Find(HttpTlsRequest.loaderGameObjName).GetComponent <HttpTlsRequest>();

            StartCoroutine(httpreq.Request("https://livedemo.xsolla.com/sdk/token/", dataArgs, (value) => {
                if (!value.HasError)
                {
                    JSONNode rootNode = JSON.Parse(value.TextRequest);
                    Logger.Log("Token - " + rootNode["token"].Value);
                    SetToken(formController, rootNode["token"].Value);
                }
                else
                {
                    Logger.Log(value.ErrorText);
                }
            }));
            // Show payment form
            //SetToken(formController, token);
            //StartCoroutine(XsollaJsonGenerator.FreshToken ((token) => SetToken(formController, token)));
        }