GetSkipChekout() public method

public GetSkipChekout ( ) : bool
return bool
示例#1
0
        public GameObject GetCardViewWeb(XsollaForm xsollaForm, XsollaTranslations translations)
        {
            GameObject cardViewObj = Instantiate(Resources.Load("Prefabs/SimpleView/_ScreenCheckout/CardViewLayoutWeb")) as GameObject;

            InputField[] inputs = cardViewObj.GetComponentsInChildren <InputField>();
            validators = new List <ValidatorInputField> ();
            for (int i = inputs.Length - 1; i >= 0; i--)
            {
                XsollaFormElement   element     = null;
                string              newErrorMsg = "Invalid";
                InputField          input       = inputs[i];
                ValidatorInputField validator   = input.GetComponentInChildren <ValidatorInputField>();
                // CVV > *HOLDER* > *ZIP* > YEAR > MONTH > NUMBER
                switch (i)               //input.tag)
                {
                case 5:                  //"CardNumber":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_NUMBER);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CARDNUMBER);
                    CCEditText ccEditText = input.GetComponent <CCEditText>();
                    isMaestro = ccEditText.IsMaestro();
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorCreditCard(newErrorMsg));
                    break;

                case 4:                        //"Month":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_EXP_MONTH);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CARD_MONTH);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorMonth(newErrorMsg));
                    break;

                case 3:                        //"Year":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_EXP_YEAR);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CARD_YEAR);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorYear(newErrorMsg));
                    break;

                case 2:                        //"Zip":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_ZIP);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_REQUIRED);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    break;

                case 1:                        //"CardHolder":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_HOLDER);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_REQUIRED);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    break;

                case 0:                        //"Cvv":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_CVV);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CVV);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorCvv(newErrorMsg, isMaestro));
                    break;

                default:
                    break;
                }

                if (element != null)
                {
                    //		input.text = element.GetTitle();
                    //						input.GetComponentInChildren<MainValidator>().setErrorMsg(newErrorMsg);
                    if (element.GetName() != XsollaApiConst.CARD_CVV)
                    {
                        input.GetComponentInChildren <Text>().text = element.GetExample();
                    }
                    // FIX update with unity 5.2
                    input.onValueChanged.AddListener(delegate { OnValueChange(input, element.GetName()); });
                }
                else
                {
                    DestroyImmediate(input.transform.parent.gameObject);
                }

                if (validator != null)
                {
                    validators.Add(validator);
                }
            }
            // Toggle allowSubscription
            // get toggle object
            Toggle toggle = cardViewObj.GetComponentInChildren <Toggle> ();

            if (xsollaForm.Contains(XsollaApiConst.ALLOW_SUBSCRIPTION))
            {
                XsollaFormElement ToggleElement = null;
                ToggleElement = xsollaForm.GetItem(XsollaApiConst.ALLOW_SUBSCRIPTION);
                // set label name
                Text lable = toggle.transform.GetComponentInChildren <Text>();
                lable.text = ToggleElement.GetTitle();
                OnValueChange(ToggleElement.GetName(), toggle.isOn?"1":"0");
                toggle.onValueChanged.AddListener((b) => {
                    OnValueChange(ToggleElement.GetName(), b?"1":"0");
                });
            }
            else
            {
                GameObject.Find(toggle.transform.parent.name).SetActive(false);
            }

            if (xsollaForm.Contains("couponCode") && xsollaForm.GetItem("couponCode").IsVisible())
            {
                GameObject          promoController = Instantiate(Resources.Load("Prefabs/SimpleView/_PaymentFormElements/ContainerPromoCode")) as GameObject;
                PromoCodeController controller      = promoController.GetComponent <PromoCodeController>();
                controller.InitScreen(translations, xsollaForm.GetItem("couponCode"));
                controller._inputField.onValueChanged.AddListener((s) => {
                    OnValueChange("couponCode", s.Trim());
                });
                controller._promoCodeApply.onClick.AddListener(() =>
                {
                    bool isLinkRequired = false;
                    if ((_form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) && _form.GetSkipChekout())
                    {
                        string checkoutToken = _form.GetCheckoutToken();
                        isLinkRequired       = checkoutToken != null &&
                                               !"".Equals(checkoutToken) &&
                                               !"null".Equals(checkoutToken) &&
                                               !"false".Equals(checkoutToken);
                    }
                    if (isLinkRequired)
                    {
                        string link = "https://secure.xsolla.com/pages/checkout/?token=" + _form.GetCheckoutToken();
                        if (Application.platform == RuntimePlatform.WebGLPlayer ||
                            Application.platform == RuntimePlatform.OSXWebPlayer ||
                            Application.platform == RuntimePlatform.WindowsWebPlayer)
                        {
                            Application.ExternalEval("window.open('" + link + "','Window title')");
                        }
                        else
                        {
                            Application.OpenURL(link);
                        }
                    }
                    gameObject.GetComponentInParent <XsollaPaystationController> ().ApplyPromoCoupone(_form.GetXpsMap());
                });
                promoController.transform.SetParent(cardViewObj.transform);
            }
            return(cardViewObj);
        }
示例#2
0
        public void InitView(XsollaTranslations pTranslations, XsollaForm form)
        {
            _form = form;
            // if have skipCheckout and this checkout form
            if ((form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) && form.GetSkipChekout())
            {
                string checkoutToken  = _form.GetCheckoutToken();
                bool   isLinkRequired = checkoutToken != null &&
                                        !"".Equals(checkoutToken) &&
                                        !"null".Equals(checkoutToken) &&
                                        !"false".Equals(checkoutToken);
                if (isLinkRequired)
                {
                    OnClickPay(isLinkRequired);
                    return;
                }
            }

            string pattern = "{{.*?}}";
            Regex  regex   = new Regex(pattern);
            string title   = regex.Replace(pTranslations.Get(XsollaTranslations.PAYMENT_PAGE_TITLE_VIA), form.GetTitle(), 1);

            layout.AddObject(GetTitle(title));
            layout.AddObject(GetError(form.GetError()));
            layout.AddObject(GetInfo(form.GetMessage()));
            if (form.GetVisible().Count > 0)
            {
                GameObject formView = GetFormView(form, pTranslations);
                layout.AddObject(formView);
            }
            if (form.GetAccountXsolla() != null && !"".Equals(form.GetAccountXsolla()) && !"null".Equals(form.GetAccountXsolla()))
            {
                layout.AddObject(GetTwoTextPlate("Xsolla number", form.GetAccountXsolla()));
            }
            if (form.GetAccount() != null && !"".Equals(form.GetAccount()) && !"null".Equals(form.GetAccount()))
            {
                layout.AddObject(GetTwoTextPlate("2pay number", form.GetAccount()));
            }
            if (form.IsValidPaymentSystem())
            {
                layout.AddObject(GetTextPlate(pTranslations.Get(XsollaTranslations.FORM_CC_EULA)));
            }
            GameObject footerInstance = Instantiate(footer);

            Text[] footerTexts = footerInstance.GetComponentsInChildren <Text> ();
//			footerTexts [0].text = "back";//back
            string nextStep = form.GetNextStepString();

            footerTexts [2].text = nextStep;            //translations.Get (XsollaTranslations.FORM_CONTINUE);//pay now
            Button[] footerButtons = footerInstance.GetComponentsInChildren <Button> ();
            if (OnClickBack != null)
            {
                footerButtons [0].onClick.AddListener(() => {
                    OnBack();
                });
            }
            else
            {
                footerButtons [0].gameObject.SetActive(false);
            }

            if (form.GetCurrentCommand() == XsollaForm.CurrentCommand.ACCOUNT ||
                form.GetCurrentCommand() == XsollaForm.CurrentCommand.CREATE ||
                form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) //
            {
                footerTexts [1].text = "";                                      //total
                RectTransform buttonRect = footerButtons [1].GetComponent <RectTransform>();
                Vector2       vecMin     = buttonRect.anchorMin;
                vecMin.x             = vecMin.x - (buttonRect.anchorMax.x - vecMin.x) / 2;
                buttonRect.anchorMin = vecMin;
            }
            else
            {
                footerTexts [1].text = pTranslations.Get(XsollaTranslations.TOTAL) + " " + form.GetSumTotal();                  //total
            }

            layout.AddObject(footerInstance);
            layout.Invalidate();

            if (!"".Equals(nextStep) && form.GetCurrentCommand() != XsollaForm.CurrentCommand.ACCOUNT)
            {
                string checkoutToken  = _form.GetCheckoutToken();
                bool   isLinkRequired = checkoutToken != null &&
                                        !"".Equals(checkoutToken) &&
                                        !"null".Equals(checkoutToken) &&
                                        !"false".Equals(checkoutToken);
                string link = "https://secure.xsolla.com/pages/checkout/?token=" + _form.GetCheckoutToken();
                if (isLinkRequired && Application.platform == RuntimePlatform.WebGLPlayer)
                {
                    RectTransform buttonRect = footerButtons [1].GetComponent <RectTransform>();
                    int           width      = (int)(buttonRect.rect.xMax - buttonRect.rect.xMin);
                    int           height     = (int)(buttonRect.rect.yMax - buttonRect.rect.yMin);
                    height = height * 8;
                    Vector3[] vec = new Vector3[4];
                    buttonRect.GetWorldCorners(vec);
                    int xPos = (int)vec[0].x;
                    int yPos = (int)vec[0].y;
                    yPos = yPos / 2;
                    CreateLinkButtonWebGl(xPos, yPos, width, height, link, "CardPaymeentForm", "Next");
                    footerButtons [1].onClick.AddListener(() => {
                        OnClickPay(false);
                    });
                }
                else
                {
                    footerButtons [1].onClick.AddListener(() => {
                        OnClickPay(isLinkRequired);
                    });
                }
            }
            else
            {
                footerButtons [1].gameObject.SetActive(false);
            }
        }
        GameObject DrawInput(XsollaFormElement element)
        {
            // if this promo coupone code then draw another prefab
            if (element.GetName() == "couponCode")
            {
                GameObject          newItem    = Instantiate(Resources.Load("Prefabs/SimpleView/_PaymentFormElements/ContainerPromoCode")) as GameObject;
                PromoCodeController controller = newItem.GetComponent <PromoCodeController>();
                controller.InitScreen(_translation, element);
                controller._inputField.onEndEdit.AddListener(delegate
                {
                    OnEndEdit(element, controller._inputField);
                });

                controller._promoCodeApply.onClick.AddListener(delegate
                {
                    bool isLinkRequired = false;
                    if ((form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) && form.GetSkipChekout())
                    {
                        string checkoutToken = form.GetCheckoutToken();
                        isLinkRequired       = checkoutToken != null &&
                                               !"".Equals(checkoutToken) &&
                                               !"null".Equals(checkoutToken) &&
                                               !"false".Equals(checkoutToken);
                    }
                    if (isLinkRequired)
                    {
                        string link = "https://secure.xsolla.com/pages/checkout/?token=" + form.GetCheckoutToken();
                        if (Application.platform == RuntimePlatform.WebGLPlayer ||
                            Application.platform == RuntimePlatform.OSXWebPlayer ||
                            Application.platform == RuntimePlatform.WindowsWebPlayer)
                        {
                            Application.ExternalEval("window.open('" + link + "','Window title')");
                        }
                        else
                        {
                            Application.OpenURL(link);
                        }
                    }
                    gameObject.GetComponentInParent <XsollaPaystationController> ().ApplyPromoCoupone(form.GetXpsMap());
                });

                return(newItem);
            }
            else
            {
                GameObject newItem = Instantiate(inputPrefab) as GameObject;
                newItem.GetComponentInChildren <Text>().text = element.GetTitle();
                InputField inputField = newItem.GetComponentInChildren <InputField>();
                inputField.GetComponentInChildren <Text>().text = element.GetExample();
                SetupValidation(element.GetName(), inputField);
                //inputField.onValidateInput += ValidateInput;
                inputField.onEndEdit.AddListener(delegate
                {
                    OnEndEdit(element, inputField);
                });
                return(newItem);
            }
        }