public void ChooseItem(Dictionary <string, object> items)
 {
     Logger.Log("Choose item request");
     TransactionHelper.SavePurchase(items);
     result = new XsollaResult(new Dictionary <string, object>(items));
     currentPurchase.Remove(ActivePurchase.Part.PID);
     currentPurchase.Remove(ActivePurchase.Part.XPS);
     FillPurchase(ActivePurchase.Part.ITEM, items);
     TryPay();
 }
        private void OnUserStatusExit(XsollaStatus.Group group, string invoice, Xsolla.XsollaStatusData.Status status, Dictionary <string, object> pPurchase = null)
        {
            Logger.Log("On user exit status screen");
            switch (group)
            {
            case XsollaStatus.Group.DONE:
                Logger.Log("Status Done");
                menuTransform.gameObject.SetActive(true);
                if (result == null)
                {
                    result = new XsollaResult();
                }
                result.invoice = invoice;
                result.status  = status;
                if (pPurchase != null)
                {
                    result.purchases = pPurchase;
                }
                Logger.Log("Ivoice ID " + result.invoice);
                Logger.Log("Status " + result.status);
                Logger.Log("Bought", result.purchases);
                TransactionHelper.Clear();

                if (OkHandler != null)
                {
                    OkHandler(result);
                }
                else
                {
                    Logger.Log("Have no OkHandler");
                }
                break;

            case XsollaStatus.Group.TROUBLED:
            case XsollaStatus.Group.INVOICE:
            case XsollaStatus.Group.UNKNOWN:
            default:
                result.invoice = invoice;
                result.status  = status;
                Logger.Log("Ivoice ID " + result.invoice);
                Logger.Log("Status " + result.status);
                Logger.Log("Bought", result.purchases);
                TransactionHelper.Clear();
                if (OkHandler != null)
                {
                    OkHandler(result);
                }
                else
                {
                    Logger.Log("Have no OkHandler");
                }
                break;
            }
        }
        void Start()
        {
            XsollaPaymentImpl           Payment = gameObject.AddComponent <XsollaPaymentImpl>() as XsollaPaymentImpl;
            Dictionary <string, object> newDict = TransactionHelper.LoadRequest();

            if (newDict != null)
            {
                Payment.GetStatus(newDict);
            }
            else
            {
                Debug.Log("Have no Unfinished requests");
            }
        }
Exemple #4
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);
        }
 private void CheckUnfinished()
 {
     Logger.Log("Check unfinished payments");
     if (TransactionHelper.CheckUnfinished())
     {
         Logger.Log("Have unfinished payments");
         Payment.StatusReceived += CheckUnfinishedPaymentStatus;
         var request = TransactionHelper.LoadRequest();
         if (request != null)
         {
             Payment.GetStatus(request);
         }
         else
         {
             TransactionHelper.Clear();
             Payment = null;
         }
     }
 }
Exemple #6
0
 public void ChooseItem(Dictionary <string, object> items, bool isVirtualPayment)
 {
     Logger.Log("Choose item request");
     if (isSimple)
     {
         TransactionHelper.SavePurchase(items);
     }
     result = new XsollaResult(new Dictionary <string, object>(items));
     currentPurchase.Remove(ActivePurchase.Part.PID);
     currentPurchase.Remove(ActivePurchase.Part.XPS);
     FillPurchase(ActivePurchase.Part.ITEM, items);
     if (!isVirtualPayment)
     {
         TryPay();
     }
     else
     {
         SetLoading(true);
         Payment.GetVPSummary(currentPurchase.GetMergedMap());
     }
 }
        public IEnumerator 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);
                }
                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);
            }

            Debug.Log(url);
            Debug.Log(sb.ToString());
            WWW www = new WWW(url, form);

            yield return(StartCoroutine(WaitForRequest(type, www, post)));
        }
Exemple #8
0
        private void OnUserStatusExit(XsollaStatus.Group group, XsollaStatusData statusData)
        {
            Logger.Log("On user exit status screen");
            switch (group)
            {
            case XsollaStatus.Group.DONE:
                Logger.Log("Status Done");
                menuTransform.gameObject.SetActive(true);
                result.invoice = statusData.GetInvoice();
                result.status  = statusData.GetStatus();
                Logger.Log("Ivoice ID " + result.invoice);
                Logger.Log("Status " + result.status);
                Logger.Log("Bought", result.purchases);
                TransactionHelper.Clear();
                if (OkHandler != null)
                {
                    OkHandler(result);
                }
                else
                {
                    Logger.Log("Have no OkHandler");
                }
                break;

            case XsollaStatus.Group.TROUBLED:
                Logger.Log("Status TROUBLED");
                TryAgain();
                break;

            case XsollaStatus.Group.INVOICE:
            case XsollaStatus.Group.UNKNOWN:
            default:
                Logger.Log("Status in proccess");
                TryAgain();
                break;
            }
        }