Exemplo n.º 1
0
        private async void SendExecute()
        {
            IsLoading = true;

            var save = _isSave ?? false;
            var info = new TLPaymentRequestedInfo();

            if (_paymentForm.Invoice.IsNameRequested)
            {
                info.Name = _info.Name;
            }
            if (_paymentForm.Invoice.IsEmailRequested)
            {
                info.Email = _info.Email;
            }
            if (_paymentForm.Invoice.IsPhoneRequested)
            {
                info.Phone = _info.Phone;
            }
            if (_paymentForm.Invoice.IsShippingAddressRequested)
            {
                info.ShippingAddress             = _info.ShippingAddress;
                info.ShippingAddress.CountryIso2 = _selectedCountry?.Code?.ToUpper();
            }

            var response = await LegacyService.ValidateRequestedInfoAsync(_message.Id, info, save);

            if (response.IsSucceeded)
            {
                IsLoading = false;

                if (_paymentForm.HasSavedInfo && !save)
                {
                    LegacyService.ClearSavedInfoAsync(true, false, null, null);
                }

                if (_paymentForm.Invoice.IsFlexible)
                {
                    //NavigationService.NavigateToPaymentFormStep2(_message, _paymentForm, info, response.Result);
                }
                else if (_paymentForm.HasSavedCredentials)
                {
                    if (ApplicationSettings.Current.TmpPassword != null)
                    {
                        if (ApplicationSettings.Current.TmpPassword.ValidUntil < TLUtils.Now + 60)
                        {
                            ApplicationSettings.Current.TmpPassword = null;
                        }
                    }

                    if (ApplicationSettings.Current.TmpPassword != null)
                    {
                        //NavigationService.NavigateToPaymentFormStep5(_message, _paymentForm, info, response.Result, null, null, null, true);
                    }
                    else
                    {
                        //NavigationService.NavigateToPaymentFormStep4(_message, _paymentForm, info, response.Result, null);
                    }
                }
                else
                {
                    //NavigationService.NavigateToPaymentFormStep3(_message, _paymentForm, info, response.Result, null);
                }
            }
            else if (response.Error != null)
            {
                IsLoading = false;

                switch (response.Error.ErrorMessage)
                {
                case "REQ_INFO_NAME_INVALID":
                case "REQ_INFO_PHONE_INVALID":
                case "REQ_INFO_EMAIL_INVALID":
                case "ADDRESS_COUNTRY_INVALID":
                case "ADDRESS_CITY_INVALID":
                case "ADDRESS_POSTCODE_INVALID":
                case "ADDRESS_STATE_INVALID":
                case "ADDRESS_STREET_LINE1_INVALID":
                case "ADDRESS_STREET_LINE2_INVALID":
                    RaisePropertyChanged(response.Error.ErrorMessage);
                    break;

                default:
                    //AlertsCreator.processError(error, PaymentFormActivity.this, req);
                    break;
                }
            }
        }