public static void CreatePaymentForm(XsollaJsonGenerator generator, Action<XsollaResult> actionOk, Action<XsollaError> actionError, bool isSandbox)
 {
     XsollaPaystationController formController = GetPaystationController();
     formController.OkHandler += actionOk;
     formController.ErrorHandler += actionError;
     formController.OpenPaystation (generator.GetPrepared(), isSandbox);
 }
示例#2
0
        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)));
        }
        public static void CreatePaymentForm(XsollaJsonGenerator generator, Action <XsollaResult> actionOk, Action <XsollaError> actionError, bool isSandbox)
        {
            XsollaPaystationController formController = GetPaystationController();

            formController.OkHandler    += actionOk;
            formController.ErrorHandler += actionError;
            formController.OpenPaystation(generator.GetPrepared(), isSandbox);
        }
示例#4
0
        public static IEnumerator FreshToken(Action<string> tokenCallback)
        {
            Logger.isLogRequired = true;
            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 ();
            string url = "https://livedemo.xsolla.com/sdk/token/";
            WWWForm form = new WWWForm ();
            form.AddField ("data", request);

            WWW www = new WWW(url, form);
            yield return www;
            if (www.error == null) {
                Logger.Log("DEBUG: Last section" + www.text);
                JSONNode rootNode = JSON.Parse(www.text);
                tokenCallback (rootNode["token"].Value);
            } else {
                tokenCallback(null);
            }
        }
示例#5
0
 public void CreatePaymentForm(XsollaJsonGenerator generator, Action<XsollaResult> actionOk, Action<XsollaError> actionError)
 {
     CreatePaymentForm (generator.GetPrepared (), actionOk, actionError);
 }