Inheritance: IParseble
Exemple #1
0
        // ---------------------------------------------------------------------------

        protected virtual void OnFormReceived(XsollaForm form)
        {
            if (FormReceived != null)
            {
                FormReceived(form);
            }
        }
Exemple #2
0
 protected virtual void OnApplyCouponeReceived(XsollaForm pForm)
 {
     if (ApplyCouponeCodeReceived != null)
     {
         ApplyCouponeCodeReceived(pForm);
     }
 }
Exemple #3
0
 protected virtual void OnStatusReceived(XsollaStatus status, XsollaForm form)
 {
     if (StatusReceived != null)
     {
         StatusReceived(status, form);
     }
 }
        protected override void ApplyPromoCouponeCode(XsollaForm pForm)
        {
            Logger.Log("Apply promo recieved");
            PromoCodeController promoController = mainScreenContainer.GetComponentInChildren <PromoCodeController>();

            if (pForm.GetError() != null)
            {
                if (pForm.GetError().elementName == XsollaApiConst.COUPON_CODE)
                {
                    promoController.SetError(pForm.GetError());
                    return;
                }
                return;
            }

            RightTowerController controller = mainScreenContainer.GetComponentInChildren <RightTowerController>();

            // update rigth tower info, if we get rigth tower controller
            if (controller != null)
            {
                controller.UpdateDiscont(Utils.GetTranslations(), pForm.GetSummary());
            }

            // update total amount on payment form total
            PaymentFormController paymentController = mainScreenContainer.GetComponentInChildren <PaymentFormController>();

            if (paymentController != null)
            {
                Text[] footerTexts = paymentController.layout.objects[paymentController.layout.objects.Count - 1].gameObject.GetComponentsInChildren <Text> ();
                footerTexts[1].text = Utils.GetTranslations().Get(XsollaTranslations.TOTAL) + " " + pForm.GetSumTotal();
            }
            promoController.ApplySuccessful();
        }
 protected override void CheckUnfinishedPaymentStatus(XsollaStatus status, XsollaForm form)
 {
     Logger.Log("Check Unfinished Payment Status");
     if (status.GetGroup() == XsollaStatus.Group.DONE)
     {
         var          purchase = TransactionHelper.LoadPurchase();
         XsollaResult result   = new XsollaResult(purchase);
         result.invoice = status.GetStatusData().GetInvoice();
         result.status  = status.GetStatusData().GetStatus();
         Logger.Log("Ivoice ID " + result.invoice);
         Logger.Log("Bought", purchase);
         if (TransactionHelper.LogPurchase(result.invoice))
         {
             if (OkHandler != null)
             {
                 OkHandler(result);
             }
         }
         else
         {
             Logger.Log("Alredy added");
         }
         TransactionHelper.Clear();
     }
 }
 protected virtual void OnNextStepRecieved(XsollaForm form)
 {
     if (NextStepRecieved != null)
     {
         NextStepRecieved(form);
     }
 }
        public void InitScreen(XsollaUtils utils, XsollaForm form)
        {
            XsollaTranslations translations = utils.GetTranslations();

            Resizer.ResizeToParrent(gameObject);
            bool isPurchaseNull = utils.GetPurchase() == null;

            if (isPurchaseNull || !utils.GetPurchase().IsPurchase() || !utils.GetPurchase().IsPaymentSystem())
            {
                if (!isPurchaseNull)
                {
                    isPrevStepPaymentList = !utils.GetPurchase().IsPaymentSystem();
                }
                paymentForm.OnClickBack += () => {
                    Back();
                };
            }
            paymentForm.InitView(translations, form);
            if (form.GetSummary() != null)
            {
                tower.InitView(translations, form.GetSummary());
            }
            else
            {
                tower.gameObject.SetActive(false);
            }
        }
        private void DrawForm(XsollaUtils utils, XsollaForm form)
        {
            currentActive = ActiveScreen.PAYMENT;
            GameObject checkoutScreen = Instantiate(Resources.Load(PREFAB_SCREEN_CHECKOUT)) as GameObject;

            checkoutScreen.transform.SetParent(mainScreenContainer.transform);
            checkoutScreen.GetComponent <RectTransform> ().anchoredPosition = new Vector2(0, 0);
            //scroll.content = paymentScreen.GetComponent<RectTransform> ();
            mainScreenContainer.GetComponentInParent <ScrollRect> ().content = checkoutScreen.GetComponent <RectTransform> ();
            ScreenCheckoutController controller = checkoutScreen.GetComponent <ScreenCheckoutController> ();

            controller.InitScreen(utils, form);
        }
        public new void OnFormReceived(XsollaForm form)
        {
            XsollaForm.CurrentCommand command = form.GetCurrentCommand();
            switch (command)
            {
            case XsollaForm.CurrentCommand.FORM:
                XsollaError error = form.GetError();
                if (!form.IsValidPaymentSystem())
                {
                    OnErrorReceived(XsollaError.GetUnsuportedError());
                }
                else if (error == null)
                {
                    form.UpdateElement(XsollaApiConst.CARD_NUMBER, _cardNumber);
                    form.UpdateElement(XsollaApiConst.CARD_EXP_YEAR, _cardExpYear);
                    form.UpdateElement(XsollaApiConst.CARD_EXP_MONTH, _cardExpMonth);
                    form.UpdateElement(XsollaApiConst.CARD_CVV, _cardCvv);
                    form.UpdateElement(XsollaApiConst.CARD_ZIP, _cardZip);
                    form.UpdateElement(XsollaApiConst.CARD_HOLDER, _cardHolder);
                    NextStep(form.GetXpsMap());
                }
                else
                {
                    OnErrorReceived(error);
                }
                break;

            case XsollaForm.CurrentCommand.CHECK:
                if (form.GetItem(XsollaApiConst.CARD_ZIP) != null)
                {
                    form.UpdateElement(XsollaApiConst.CARD_ZIP, _cardZip);
                    NextStep(form.GetXpsMap());
                }
                else
                {
                    OnNextStepRecieved(form);
                }
                break;

            case XsollaForm.CurrentCommand.ACCOUNT:
            case XsollaForm.CurrentCommand.STATUS:
            case XsollaForm.CurrentCommand.CREATE:
            default:
                break;
            }
        }
 public void InitScreen(XsollaUtils utils, XsollaForm form)
 {
     XsollaTranslations translations = utils.GetTranslations ();
     Resizer.ResizeToParrent (gameObject);
     bool isPurchaseNull = utils.GetPurchase () == null;
     if (isPurchaseNull || !utils.GetPurchase ().IsPurchase () || !utils.GetPurchase ().IsPaymentSystem ()) {
         if(!isPurchaseNull)
             isPrevStepPaymentList = !utils.GetPurchase ().IsPaymentSystem ();
         paymentForm.OnClickBack += () => {
             Back ();};
     }
     paymentForm.InitView (translations, form);
     if (form.GetSummary () != null)
         tower.InitView (translations, form.GetSummary ());
     else
         tower.gameObject.SetActive (false);
 }
Exemple #11
0
        public GameObject GetFormView(XsollaForm xsollaForm, XsollaTranslations translations)
        {
            bool isCcRender = xsollaForm.GetCurrentCommand() == XsollaForm.CurrentCommand.FORM && xsollaForm.IsCreditCard();

            if (isCcRender)
            {
                return(GetCardViewWeb(xsollaForm, translations));
            }
            else
            {
                FormElementAdapter adapter = GetComponent <FormElementAdapter>();
                adapter.SetForm(xsollaForm, translations);
                GameObject list = GetList(adapter);
                list.GetComponent <ListView>().DrawList(GetComponent <RectTransform> ());
                return(list);
            }
        }
Exemple #12
0
 public new void OnFormReceived(XsollaForm form)
 {
     XsollaForm.CurrentCommand command = form.GetCurrentCommand ();
     switch (command) {
         case XsollaForm.CurrentCommand.FORM:
                 XsollaError error = form.GetError();
                 if (!form.IsValidPaymentSystem ()) {
                     OnErrorReceived (XsollaError.GetUnsuportedError ());
                 } else if (error == null) {
                     form.UpdateElement (XsollaApiConst.CARD_NUMBER, _cardNumber);
                     form.UpdateElement (XsollaApiConst.CARD_EXP_YEAR, _cardExpYear);
                     form.UpdateElement (XsollaApiConst.CARD_EXP_MONTH, _cardExpMonth);
                     form.UpdateElement (XsollaApiConst.CARD_CVV, _cardCvv);
                     form.UpdateElement (XsollaApiConst.CARD_ZIP, _cardZip);
                     form.UpdateElement (XsollaApiConst.CARD_HOLDER, _cardHolder);
                     NextStep (form.GetXpsMap());
                 } else {
                     OnErrorReceived (error);
                 }
             break;
         case XsollaForm.CurrentCommand.CHECK:
             if(form.GetItem(XsollaApiConst.CARD_ZIP) != null)
             {
                 form.UpdateElement (XsollaApiConst.CARD_ZIP, _cardZip);
                 NextStep (form.GetXpsMap());
             } else {
                 OnNextStepRecieved(form);
             }
             break;
         case XsollaForm.CurrentCommand.ACCOUNT:
         case XsollaForm.CurrentCommand.STATUS:
         case XsollaForm.CurrentCommand.CREATE:
         default:
             break;
     }
 }
Exemple #13
0
 protected abstract void CheckUnfinishedPaymentStatus(XsollaStatus status, XsollaForm form);
        protected override void ApplyPromoCouponeCode(XsollaForm pForm)
        {
            Logger.Log("Apply promo recieved");
            PromoCodeController promoController = mainScreenContainer.GetComponentInChildren<PromoCodeController>();
            if (pForm.GetError() != null)
            {
                if (pForm.GetError().elementName == XsollaApiConst.COUPON_CODE)
                {
                    promoController.SetError(pForm.GetError());
                    return;
                }
                return;
            }

            RightTowerController controller = mainScreenContainer.GetComponentInChildren<RightTowerController>();
            // update rigth tower info, if we get rigth tower controller
            if (controller != null)
                controller.UpdateDiscont(Utils.GetTranslations(),pForm.GetSummary());

            // update total amount on payment form total
            PaymentFormController paymentController = mainScreenContainer.GetComponentInChildren<PaymentFormController>();
            if (paymentController != null)
            {
                Text[] footerTexts = paymentController.layout.objects[paymentController.layout.objects.Count - 1].gameObject.GetComponentsInChildren<Text> ();
                footerTexts[1].text = Utils.GetTranslations().Get(XsollaTranslations.TOTAL) + " " + pForm.GetSumTotal ();
            }
            promoController.ApplySuccessful();
        }
 protected override void CheckUnfinishedPaymentStatus(XsollaStatus status, XsollaForm form)
 {
     Logger.Log ("Check Unfinished Payment Status");
     if (status.GetGroup () == XsollaStatus.Group.DONE) {
         var purchase = TransactionHelper.LoadPurchase();
         XsollaResult result = new XsollaResult(purchase);
         result.invoice = status.GetStatusData().GetInvoice ();
         result.status = status.GetStatusData().GetStatus ();
         Logger.Log("Ivoice ID " + result.invoice);
         Logger.Log("Bought", purchase);
         if(TransactionHelper.LogPurchase(result.invoice)) {
             if (OkHandler != null)
                 OkHandler (result);
         } else {
                 Logger.Log("Alredy added");
         }
         TransactionHelper.Clear();
     }
 }
Exemple #16
0
        private void ProcessingRequestResult(int pType, RequestClass pRequestResult, Dictionary <string, object> pDataArgs)
        {
            if (!pRequestResult.HasError)
            {
                // Start Processing
                Debug.Log("Type -> " + pType);
                Debug.Log("WWW_request -> " + pRequestResult.TextRequest);

                JSONNode rootNode = JSON.Parse(pRequestResult.TextRequest);
                if (rootNode != null && rootNode.Count > 2 || rootNode["error"] == null)
                {
                    switch (pType)
                    {
                    case TRANSLATIONS:
                    {
                        if (rootNode.Count > 2)
                        {
                            XsollaUtils utils = new XsollaUtils().Parse(rootNode) as XsollaUtils;
                            projectId = utils.GetProject().id.ToString();

                            OnUtilsRecieved(utils);
                            // if base param not containKey access token, then add token from util
                            if (!baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
                            {
                                _accessToken = utils.GetAcceessToken();
                            }
                            OnTranslationRecieved(utils.GetTranslations());
                        }
                        else
                        {
                            XsollaError error = new XsollaError();
                            error.Parse(rootNode);
                            OnErrorReceived(error);
                        }
                    }
                    break;

                    case DIRECTPAYMENT_FORM:
                    {
                        if (rootNode.Count > 8)
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            switch (form.GetCurrentCommand())
                            {
                            case XsollaForm.CurrentCommand.STATUS:
                                GetStatus(form.GetXpsMap());
                                break;

                            case XsollaForm.CurrentCommand.CHECKOUT:
                            case XsollaForm.CurrentCommand.CHECK:
                            case XsollaForm.CurrentCommand.FORM:
                            case XsollaForm.CurrentCommand.CREATE:
                            case XsollaForm.CurrentCommand.ACCOUNT:
                                OnFormReceived(form);
                                break;

                            case XsollaForm.CurrentCommand.UNKNOWN:
                                if (rootNode.Count > 10)
                                {
                                    OnFormReceived(form);
                                }
                                else
                                {
                                    XsollaError error = new XsollaError();
                                    error.Parse(rootNode);
                                    OnErrorReceived(error);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            XsollaStatusPing statusPing = new XsollaStatusPing();
                            statusPing.Parse(rootNode);
                            OnStatusChecked(statusPing);
                        }
                    }
                    break;

                    case DIRECTPAYMENT_STATUS:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        XsollaStatus status = new XsollaStatus();
                        status.Parse(rootNode);
                        OnStatusReceived(status, form);
                    }
                    break;

                    case PRICEPOINTS:
                    {
                        XsollaPricepointsManager pricepoints = new XsollaPricepointsManager();
                        pricepoints.Parse(rootNode);
                        OnPricepointsRecieved(pricepoints);
                    }
                    break;

                    case GOODS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                    }
                    break;

                    case GOODS_GROUPS:
                    {
                        XsollaGroupsManager groups = new XsollaGroupsManager();
                        groups.Parse(rootNode);
                        OnGoodsGroupsRecieved(groups);
                    }
                    break;

                    case GOODS_ITEMS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                    }
                    break;

                    case PAYMENT_LIST:
                    {
                        XsollaPaymentMethods paymentMethods = new XsollaPaymentMethods();
                        paymentMethods.Parse(rootNode);
                        OnPaymentMethodsRecieved(paymentMethods);
                    }
                    break;

                    case SAVED_PAYMENT_LIST:
                    {
                        XsollaSavedPaymentMethods savedPaymentsMethods = new XsollaSavedPaymentMethods();
                        savedPaymentsMethods.Parse(rootNode);
                        OnSavedPaymentMethodsRecieved(savedPaymentsMethods);
                    }
                    break;

                    case QUICK_PAYMENT_LIST:
                    {
                        XsollaQuickPayments quickPayments = new XsollaQuickPayments();
                        quickPayments.Parse(rootNode);
                        OnQuickPaymentMethodsRecieved(quickPayments);
                    }
                    break;

                    case COUNTRIES:
                    {
                        XsollaCountries countries = new XsollaCountries();
                        countries.Parse(rootNode);
                        OnCountriesRecieved(countries);
                    }
                    break;

                    case VIRTUAL_PAYMENT_SUMMARY:
                    {
                        XVirtualPaymentSummary summary = new XVirtualPaymentSummary();
                        summary.Parse(rootNode);
                        Logger.Log("VIRTUAL_PAYMENT_SUMMARY " + summary.ToString());
                        if (summary.IsSkipConfirmation)
                        {
                            Logger.Log("IsSkipConfirmation true");
                            pDataArgs.Add("dont_ask_again", 0);
                            ProceedVPayment(pDataArgs);
                        }
                        else
                        {
                            Logger.Log("IsSkipConfirmation false");
                            OnVPSummaryRecieved(summary);
                        }
                    }
                    break;

                    case VIRTUAL_PROCEED:
                    {
                        XProceed proceed = new XProceed();
                        proceed.Parse(rootNode);
                        Logger.Log("VIRTUAL_PROCEED " + proceed.ToString());
                        if (proceed.IsInvoiceCreated)
                        {
                            Logger.Log("VIRTUAL_PROCEED 1");
                            long operationId = proceed.OperationId;
                            pDataArgs.Add("operation_id", operationId);
                            VPaymentStatus(pDataArgs);
                        }
                        else
                        {
                            Logger.Log("VIRTUAL_PROCEED 0 ");
                            OnVPProceedError(proceed.Error);
                        }
                    }
                    break;

                    case VIRTUAL_STATUS:
                    {
                        XVPStatus vpStatus = new XVPStatus();
                        vpStatus.Parse(rootNode);
                        //{"errors":[ {"message":"Insufficient balance to complete operation"} ], "api":{"ver":"1.0.1"}, "invoice_created":"false", "operation_id":"0", "code":"0"}
                        Logger.Log("VIRTUAL_STATUS" + vpStatus.ToString());
                        OnVPStatusRecieved(vpStatus);
                    }
                    break;

                    case APPLY_PROMO_COUPONE:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        OnApplyCouponeReceived(form);
                    }
                    break;

                    case COUPON_PROCEED:
                    {
                        XsollaCouponProceedResult couponProceed = new XsollaCouponProceedResult();
                        couponProceed.Parse(rootNode);
                        if (couponProceed._error != null)
                        {
                            Logger.Log("COUPON_PROCEED ERROR: " + couponProceed._error);
                            OnCouponProceedErrorRecived(couponProceed);
                        }
                        else
                        {
                            long operationId = couponProceed._operationId;
                            if (pDataArgs.ContainsKey("coupon_code"))
                            {
                                pDataArgs.Remove("coupon_code");
                            }
                            pDataArgs.Add("operation_id", operationId);
                            VPaymentStatus(pDataArgs);
                        }
                    }
                    break;

                    case HISTORY:
                    {
                        XsollaHistoryList history = new XsollaHistoryList().Parse(rootNode["operations"]) as XsollaHistoryList;
                        OnHistoryRecieved(history);
                    }
                    break;

                    case CALCULATE_CUSTOM_AMOUNT:
                    {
                        //TODO: fill method
                        CustomVirtCurrAmountController.CustomAmountCalcRes res = new CustomVirtCurrAmountController.CustomAmountCalcRes().Parse(rootNode["calculation"]) as CustomVirtCurrAmountController.CustomAmountCalcRes;
                        OnCustomAmountResRecieved(res);
                    }
                    break;

                    default:
                        break;
                    }
                }
                else
                {
                    XsollaError error = new XsollaError();
                    error.Parse(rootNode);
                    OnErrorReceived(error);
                }
            }
            else
            {
                JSONNode errorNode = JSON.Parse(pRequestResult.TextRequest);
                string   errorMsg  = errorNode["errors"].AsArray[0]["message"].Value
                                     + ". Support code " + errorNode["errors"].AsArray[0]["support_code"].Value;
                int errorCode = 0;
                if (pRequestResult.ErrorText.Length > 3)
                {
                    errorCode = int.Parse(pRequestResult.ErrorText.Substring(0, 3));
                }
                else
                {
                    errorCode = int.Parse(pRequestResult.ErrorText);
                }
                OnErrorReceived(new XsollaError(errorCode, errorMsg));
            }
            if (projectId != null && !"".Equals(projectId))
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", projectId, pRequestResult.Url);
            }
            else
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", "undefined", pRequestResult.Url);
            }
        }
 protected override void ShowPaymentForm(XsollaUtils utils, XsollaForm form)
 {
     Logger.Log ("Payment Form recived");
     DrawForm (utils, form);
     SetLoading (false);
 }
 private void DrawForm(XsollaUtils utils, XsollaForm form)
 {
     currentActive = ActiveScreen.PAYMENT;
     GameObject checkoutScreen = Instantiate (Resources.Load(PREFAB_SCREEN_CHECKOUT)) as GameObject;
     checkoutScreen.transform.SetParent(mainScreenContainer.transform);
     checkoutScreen.GetComponent<RectTransform> ().anchoredPosition = new Vector2 (0, 0);
     //scroll.content = paymentScreen.GetComponent<RectTransform> ();
     mainScreenContainer.GetComponentInParent<ScrollRect> ().content = checkoutScreen.GetComponent<RectTransform> ();
     ScreenCheckoutController controller = checkoutScreen.GetComponent<ScreenCheckoutController> ();
     controller.InitScreen(utils, form);
 }
        private IEnumerator WaitForRequest(int pType, WWW www, Dictionary <string, object> post)
        {
            Logger.Log("Start get www");
            yield return(www);

            // check for errors
            if (www.error == null)
            {
                Debug.Log("Type -> " + pType);
                Debug.Log("WWW_request -> " + www.text);
                string data = www.text;

                JSONNode rootNode = JSON.Parse(www.text);
                if (rootNode != null && rootNode.Count > 2 || rootNode["error"] == null)
                {
                    switch (pType)
                    {
                    case TRANSLATIONS:
                    {
                        if (rootNode.Count > 2)
                        {
                            XsollaUtils utils = new XsollaUtils().Parse(rootNode) as XsollaUtils;
                            projectId = utils.GetProject().id.ToString();
                            if (baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
                            {
                                utils.SetAccessToken(baseParams[XsollaApiConst.ACCESS_TOKEN].ToString());
                            }

                            OnUtilsRecieved(utils);
//								// if base param not containKey access token, then add token from util
//								if (!baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
//									_accessToken = utils.GetAcceessToken();
                            OnTranslationRecieved(utils.GetTranslations());
                        }
                        else
                        {
                            XsollaError error = new XsollaError();
                            error.Parse(rootNode);
                            OnErrorReceived(error);
                        }
                        break;
                    }

                    case DIRECTPAYMENT_FORM:
                    {
                        if (rootNode.Count > 8)
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            switch (form.GetCurrentCommand())
                            {
                            case XsollaForm.CurrentCommand.STATUS:
                                // if we replaced or add saved account, we must start loop on get list saved account
                                if (post.ContainsKey("save_payment_account_only") || (post.ContainsKey("replace_payment_account")))
                                {
                                    if (!form.IsCardPayment() && !(post.ContainsKey("replace_payment_account")))
                                    {
                                        OnWaitPaymentChange();
                                        break;
                                    }
                                    else
                                    {
                                        OnPaymentManagerMethod(null, post.ContainsKey("replace_payment_account")?false:true);
                                        break;
                                    }
                                }
                                GetStatus(form.GetXpsMap());
                                break;

                            case XsollaForm.CurrentCommand.CHECKOUT:
                            case XsollaForm.CurrentCommand.CHECK:
                            case XsollaForm.CurrentCommand.FORM:
                            case XsollaForm.CurrentCommand.CREATE:
                            case XsollaForm.CurrentCommand.ACCOUNT:
                                OnFormReceived(form);
                                break;

                            case XsollaForm.CurrentCommand.UNKNOWN:
                                if (rootNode.Count > 10)
                                {
                                    OnFormReceived(form);
                                }
                                else
                                {
                                    XsollaError error = new XsollaError();
                                    error.Parse(rootNode);
                                    OnErrorReceived(error);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            XsollaStatusPing statusPing = new XsollaStatusPing();
                            statusPing.Parse(rootNode);
                            OnStatusChecked(statusPing);
                        }
                        break;
                    }

                    case DIRECTPAYMENT_STATUS:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        XsollaStatus status = new XsollaStatus();
                        status.Parse(rootNode);
                        OnStatusReceived(status, form);
                        break;
                    }

                    case PRICEPOINTS:
                    {
                        XsollaPricepointsManager pricepoints = new XsollaPricepointsManager();
                        pricepoints.Parse(rootNode);
                        OnPricepointsRecieved(pricepoints);
                        break;
                    }

                    case GOODS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                        break;
                    }

                    case GOODS_GROUPS:
                    {
                        XsollaGroupsManager groups = new XsollaGroupsManager();
                        groups.Parse(rootNode);
                        OnGoodsGroupsRecieved(groups);
                        break;
                    }

                    case GOODS_ITEMS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                        break;
                    }

                    case PAYMENT_LIST:
                    {
                        XsollaPaymentMethods paymentMethods = new XsollaPaymentMethods();
                        paymentMethods.Parse(rootNode);
                        OnPaymentMethodsRecieved(paymentMethods);
                        break;
                    }

                    case SAVED_PAYMENT_LIST:
                    {
                        XsollaSavedPaymentMethods savedPaymentsMethods = new XsollaSavedPaymentMethods();
                        savedPaymentsMethods.Parse(rootNode);
                        OnSavedPaymentMethodsRecieved(savedPaymentsMethods);
                        break;
                    }

                    case QUICK_PAYMENT_LIST:
                    {
                        XsollaQuickPayments quickPayments = new XsollaQuickPayments();
                        quickPayments.Parse(rootNode);
                        OnQuickPaymentMethodsRecieved(quickPayments);
                        break;
                    }

                    case COUNTRIES:
                    {
                        XsollaCountries countries = new XsollaCountries();
                        countries.Parse(rootNode);
                        OnCountriesRecieved(countries);
                        break;
                    }

                    case VIRTUAL_PAYMENT_SUMMARY:
                    {
                        XVirtualPaymentSummary summary = new XVirtualPaymentSummary();
                        summary.Parse(rootNode);
                        Logger.Log("VIRTUAL_PAYMENT_SUMMARY " + summary.ToString());
                        if (summary.IsSkipConfirmation)
                        {
                            Logger.Log("IsSkipConfirmation true");
                            post.Add("dont_ask_again", 0);
                            ProceedVPayment(post);
                        }
                        else
                        {
                            Logger.Log("IsSkipConfirmation false");
                            OnVPSummaryRecieved(summary);
                        }
                        break;
                    }

                    case VIRTUAL_PROCEED:
                    {
                        XProceed proceed = new XProceed();
                        proceed.Parse(rootNode);
                        Logger.Log("VIRTUAL_PROCEED " + proceed.ToString());
                        if (proceed.IsInvoiceCreated)
                        {
                            Logger.Log("VIRTUAL_PROCEED 1");
                            long operationId = proceed.OperationId;
                            post.Add("operation_id", operationId);
                            VPaymentStatus(post);
                        }
                        else
                        {
                            Logger.Log("VIRTUAL_PROCEED 0 ");
                            OnVPProceedError(proceed.Error);
                        }
                        break;
                    }

                    case VIRTUAL_STATUS:
                    {
                        XVPStatus vpStatus = new XVPStatus();
                        vpStatus.Parse(rootNode);
                        Logger.Log("VIRTUAL_STATUS" + vpStatus.ToString());
                        OnVPStatusRecieved(vpStatus);
                        break;
                    }

                    case APPLY_PROMO_COUPONE:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        OnApplyCouponeReceived(form);
                        break;
                    }

                    case COUPON_PROCEED:
                    {
                        XsollaCouponProceedResult couponProceed = new XsollaCouponProceedResult();
                        couponProceed.Parse(rootNode);
                        if (couponProceed._error != null)
                        {
                            Logger.Log("COUPON_PROCEED ERROR: " + couponProceed._error);
                            OnCouponProceedErrorRecived(couponProceed);
                        }
                        else
                        {
                            long operationId = couponProceed._operationId;
                            if (post.ContainsKey("coupon_code"))
                            {
                                post.Remove("coupon_code");
                            }
                            post.Add("operation_id", operationId);

                            VPaymentStatus(post);
                        }
                        break;
                    }

                    case CALCULATE_CUSTOM_AMOUNT:
                    {
                        CustomVirtCurrAmountController.CustomAmountCalcRes res = new CustomVirtCurrAmountController.CustomAmountCalcRes().Parse(rootNode["calculation"]) as CustomVirtCurrAmountController.CustomAmountCalcRes;
                        OnCustomAmountResRecieved(res);
                        break;
                    }

                    case PAYMENT_MANAGER_LIST:
                    {
                        XsollaSavedPaymentMethods res = new XsollaSavedPaymentMethods().Parse(rootNode) as XsollaSavedPaymentMethods;
                        OnPaymentManagerMethod(res, false);
                        break;
                    }

                    case DELETE_SAVED_METHOD:
                    {
                        OnDeleteSavedPaymentMethod();
                        break;
                    }

                    case SUBSCRIPTIONS_MANAGER_LIST:
                    {
                        XsollaManagerSubscriptions lSubsList = new XsollaManagerSubscriptions().Parse(rootNode["subscriptions"]) as XsollaManagerSubscriptions;
                        OnManageSubsListrecived(lSubsList);
                        break;
                    }

                    default:
                        break;
                    }
                }
                else
                {
                    XsollaError error = new XsollaError();
                    error.Parse(rootNode);
                    OnErrorReceived(error);
                }
            }
            else
            {
                JSONNode errorNode = JSON.Parse(www.text);
                string   errorMsg  = errorNode["errors"].AsArray[0]["message"].Value
                                     + ". Support code " + errorNode["errors"].AsArray[0]["support_code"].Value;
                int errorCode = 0;
                if (www.error.Length > 3)
                {
                    errorCode = int.Parse(www.error.Substring(0, 3));
                }
                else
                {
                    errorCode = int.Parse(www.error);
                }
                OnErrorReceived(new XsollaError(errorCode, errorMsg));
            }
            if (projectId != null && !"".Equals(projectId))
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", projectId, www.url);
            }
            else
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", "undefined", www.url);
            }
        }
 protected abstract void ShowPaymentForm(XsollaUtils utils, XsollaForm form);
        private void ProcessingRequestResult(int pType, RequestClass pRequestResult, Dictionary<string, object> pDataArgs)
        {
            if (!pRequestResult.HasError)
            {
                // Start Processing
                Debug.Log("Type -> " + pType);
                Debug.Log("WWW_request -> " + pRequestResult.TextRequest);

                JSONNode rootNode = JSON.Parse(pRequestResult.TextRequest);
                if(rootNode != null && rootNode.Count > 2 || rootNode["error"] == null) {
                    switch(pType)
                    {
                    case TRANSLATIONS:
                        {
                            if(rootNode.Count > 2){
                                XsollaUtils utils = new XsollaUtils().Parse(rootNode) as XsollaUtils;
                                projectId = utils.GetProject().id.ToString();

                                OnUtilsRecieved(utils);
                                // if base param not containKey access token, then add token from util
                                if (!baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
                                    _accessToken = utils.GetAcceessToken();
                                OnTranslationRecieved(utils.GetTranslations());
                            } else {
                                XsollaError error = new XsollaError();
                                error.Parse(rootNode);
                                OnErrorReceived(error);
                            }
                        }
                        break;
                    case DIRECTPAYMENT_FORM:
                        {
                            if(rootNode.Count > 8) {
                                XsollaForm form = new XsollaForm();
                                form.Parse(rootNode);
                                switch (form.GetCurrentCommand()) {
                                case XsollaForm.CurrentCommand.STATUS:
                                    GetStatus(form.GetXpsMap());
                                    break;
                                case XsollaForm.CurrentCommand.CHECKOUT:
                                case XsollaForm.CurrentCommand.CHECK:
                                case XsollaForm.CurrentCommand.FORM:
                                case XsollaForm.CurrentCommand.CREATE:
                                case XsollaForm.CurrentCommand.ACCOUNT:
                                    OnFormReceived(form);
                                    break;
                                case XsollaForm.CurrentCommand.UNKNOWN:
                                    if(rootNode.Count > 10)
                                    {
                                        OnFormReceived(form);
                                    } else {
                                        XsollaError error = new XsollaError();
                                        error.Parse(rootNode);
                                        OnErrorReceived(error);
                                    }
                                    break;
                                default:
                                    break;
                                }
                            } else {
                                XsollaStatusPing statusPing = new XsollaStatusPing();
                                statusPing.Parse(rootNode);
                                OnStatusChecked(statusPing);
                            }
                        }
                        break;
                    case DIRECTPAYMENT_STATUS:
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            XsollaStatus status = new XsollaStatus();
                            status.Parse(rootNode);
                            OnStatusReceived(status, form);
                        }
                        break;
                    case PRICEPOINTS:
                        {
                            XsollaPricepointsManager pricepoints = new XsollaPricepointsManager();
                            pricepoints.Parse(rootNode);
                            OnPricepointsRecieved(pricepoints);
                        }
                        break;
                    case GOODS:
                        {
                            XsollaGoodsManager goods = new XsollaGoodsManager();
                            goods.Parse(rootNode);
                            OnGoodsRecieved(goods);
                        }
                        break;
                    case GOODS_GROUPS:
                        {
                            XsollaGroupsManager groups = new XsollaGroupsManager();
                            groups.Parse(rootNode);
                            OnGoodsGroupsRecieved(groups);
                        }
                        break;
                    case GOODS_ITEMS:
                        {
                            XsollaGoodsManager goods = new XsollaGoodsManager();
                            goods.Parse(rootNode);
                            OnGoodsRecieved(goods);
                        }
                        break;
                    case PAYMENT_LIST:
                        {
                            XsollaPaymentMethods paymentMethods = new XsollaPaymentMethods();
                            paymentMethods.Parse(rootNode);
                            OnPaymentMethodsRecieved(paymentMethods);
                        }
                        break;
                    case SAVED_PAYMENT_LIST:
                        {
                            XsollaSavedPaymentMethods savedPaymentsMethods = new XsollaSavedPaymentMethods();
                            savedPaymentsMethods.Parse(rootNode);
                            OnSavedPaymentMethodsRecieved(savedPaymentsMethods);
                        }
                        break;
                    case QUICK_PAYMENT_LIST:
                        {
                            XsollaQuickPayments quickPayments = new XsollaQuickPayments();
                            quickPayments.Parse(rootNode);
                            OnQuickPaymentMethodsRecieved(quickPayments);
                        }
                        break;
                    case COUNTRIES:
                        {
                            XsollaCountries countries = new XsollaCountries();
                            countries.Parse(rootNode);
                            OnCountriesRecieved(countries);
                        }
                        break;
                    case VIRTUAL_PAYMENT_SUMMARY:
                        {
                            XVirtualPaymentSummary summary = new XVirtualPaymentSummary();
                            summary.Parse(rootNode);
                            Logger.Log("VIRTUAL_PAYMENT_SUMMARY " + summary.ToString());
                            if(summary.IsSkipConfirmation) {
                                Logger.Log("IsSkipConfirmation true");
                                pDataArgs.Add("dont_ask_again", 0);
                                ProceedVPayment(pDataArgs);
                            } else {
                                Logger.Log("IsSkipConfirmation false");
                                OnVPSummaryRecieved(summary);
                            }
                        }
                        break;
                    case VIRTUAL_PROCEED:
                        {
                            XProceed proceed = new XProceed();
                            proceed.Parse(rootNode);
                            Logger.Log ("VIRTUAL_PROCEED " + proceed.ToString());
                            if(proceed.IsInvoiceCreated) {
                                Logger.Log ("VIRTUAL_PROCEED 1");
                                long operationId = proceed.OperationId;
                                pDataArgs.Add("operation_id", operationId);
                                VPaymentStatus(pDataArgs);
                            } else {
                                Logger.Log ("VIRTUAL_PROCEED 0 ");
                                OnVPProceedError(proceed.Error);
                            }
                        }
                        break;
                    case VIRTUAL_STATUS:
                        {
                            XVPStatus vpStatus = new XVPStatus();
                            vpStatus.Parse(rootNode);
                            //{"errors":[ {"message":"Insufficient balance to complete operation"} ], "api":{"ver":"1.0.1"}, "invoice_created":"false", "operation_id":"0", "code":"0"}
                            Logger.Log ("VIRTUAL_STATUS" + vpStatus.ToString());
                            OnVPStatusRecieved(vpStatus);
                        }
                        break;

                    case APPLY_PROMO_COUPONE:
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            OnApplyCouponeReceived(form);
                        }
                        break;
                    case COUPON_PROCEED:
                        {
                            XsollaCouponProceedResult couponProceed = new XsollaCouponProceedResult();
                            couponProceed.Parse(rootNode);
                            if (couponProceed._error != null)
                            {
                                Logger.Log("COUPON_PROCEED ERROR: " + couponProceed._error);
                                OnCouponProceedErrorRecived(couponProceed);
                            }
                            else
                            {
                                long operationId = couponProceed._operationId;
                                if (pDataArgs.ContainsKey("coupon_code"))
                                    pDataArgs.Remove("coupon_code");
                                pDataArgs.Add("operation_id", operationId);
                                VPaymentStatus(pDataArgs);
                            }
                        }
                        break;

                    case HISTORY:
                        {
                            XsollaHistoryList history = new XsollaHistoryList().Parse(rootNode["operations"]) as XsollaHistoryList;
                            OnHistoryRecieved(history);

                        }
                        break;
                    case CALCULATE_CUSTOM_AMOUNT:
                        {
                            //TODO: fill method
                            CustomVirtCurrAmountController.CustomAmountCalcRes res = new CustomVirtCurrAmountController.CustomAmountCalcRes().Parse(rootNode["calculation"]) as CustomVirtCurrAmountController.CustomAmountCalcRes;
                            OnCustomAmountResRecieved(res);
                        }
                        break;
                    default:
                        break;
                    }
                } else {
                    XsollaError error = new XsollaError();
                    error.Parse(rootNode);
                    OnErrorReceived(error);
                }
            }
            else
            {
                JSONNode errorNode = JSON.Parse(pRequestResult.TextRequest);
                string errorMsg = errorNode["errors"].AsArray[0]["message"].Value
                    + ". Support code " + errorNode["errors"].AsArray[0]["support_code"].Value;
                int errorCode = 0;
                if(pRequestResult.ErrorText.Length > 3)
                    errorCode = int.Parse(pRequestResult.ErrorText.Substring(0, 3));
                else
                    errorCode = int.Parse(pRequestResult.ErrorText);
                OnErrorReceived(new XsollaError(errorCode, errorMsg));
            }
            if(projectId != null && !"".Equals(projectId))
                LogEvent ("UNITY " + SDK_VERSION + " REQUEST", projectId, pRequestResult.Url);
            else
                LogEvent ("UNITY " + SDK_VERSION + " REQUEST", "undefined", pRequestResult.Url);
        }
 protected virtual void OnStatusReceived(XsollaStatus status, XsollaForm form)
 {
     if (StatusReceived != null)
         StatusReceived(status, form);
 }
Exemple #23
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);
        }
 protected override void ShowPaymentForm(XsollaUtils utils, XsollaForm form)
 {
     Logger.Log("Payment Form recived");
     DrawForm(utils, form);
     SetLoading(false);
 }
Exemple #25
0
 protected abstract void ApplyPromoCouponeCode(XsollaForm pForm);
 public void SetForm(XsollaForm form, XsollaTranslations pTranslation = null)
 {
     this.form         = form;
     this.elements     = form.GetVisible();
     this._translation = pTranslation;
 }
 protected virtual void OnApplyCouponeReceived(XsollaForm pForm)
 {
     if (ApplyCouponeCodeReceived != null)
         ApplyCouponeCodeReceived(pForm);
 }
 // ---------------------------------------------------------------------------
 protected virtual void OnFormReceived(XsollaForm form)
 {
     if (FormReceived != null)
         FormReceived(form);
 }
Exemple #29
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);
            }
        }
Exemple #30
0
 protected virtual void OnNextStepRecieved(XsollaForm form)
 {
     if (NextStepRecieved != null)
         NextStepRecieved(form);
 }