public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo, TLShippingOption>(from);

                Message     = tuple.Item1;
                Invoice     = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm = tuple.Item2;

                // TODO: real hint
                PasswordHint = Strings.Android.LoginPassword;

                if (_paymentForm.HasSavedCredentials && _paymentForm.SavedCredentials is TLPaymentSavedCredentialsCard savedCard)
                {
                    CredentialsTitle = savedCard.Title;
                }

                _info          = tuple.Item3;
                _requestedInfo = tuple.Item4;
                _shipping      = tuple.Item5;
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 2
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo, TLShippingOption>(from);

                Message     = tuple.Item1;
                Invoice     = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm = tuple.Item2;

                _info          = tuple.Item3;
                _requestedInfo = tuple.Item4;
                _shipping      = tuple.Item5;

                if (_paymentForm.HasNativeProvider && _paymentForm.HasNativeParams && _paymentForm.NativeProvider.Equals("stripe"))
                {
                    IsNativeUsed    = true;
                    SelectedCountry = null;

                    var json = JsonObject.Parse(_paymentForm.NativeParams.Data);

                    NeedCountry        = json.GetNamedBoolean("need_country", false);
                    NeedZip            = json.GetNamedBoolean("need_zip", false);
                    NeedCardholderName = json.GetNamedBoolean("need_cardholder_name", false);

                    _publishableKey = json.GetNamedString("publishable_key", string.Empty);
                }
                else
                {
                    IsNativeUsed = false;
                    RaisePropertyChanged("Navigate");
                }

                //var info = PaymentForm.HasSavedInfo ? PaymentForm.SavedInfo : new TLPaymentRequestedInfo();
                //if (info.ShippingAddress == null)
                //{
                //    info.ShippingAddress = new TLPostAddress();
                //}

                //Info = info;
                //SelectedCountry = null;
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 3
0
        public override Task OnNavigatedToAsync(object parameter, NavigationMode mode, IDictionary <string, object> state)
        {
            var buffer = parameter as byte[];

            if (buffer == null)
            {
                return(Task.CompletedTask);
            }

            using (var from = TLObjectSerializer.CreateReader(buffer.AsBuffer()))
            {
                var tuple = new TLTuple <TLMessage, TLPaymentsPaymentForm, TLPaymentRequestedInfo, TLPaymentsValidatedRequestedInfo, TLShippingOption, string, string, bool>(from);

                Message          = tuple.Item1;
                Invoice          = tuple.Item1.Media as TLMessageMediaInvoice;
                PaymentForm      = tuple.Item2;
                Info             = tuple.Item3;
                Shipping         = tuple.Item5;
                CredentialsTitle = string.IsNullOrEmpty(tuple.Item6) ? null : tuple.Item6;
                Bot      = tuple.Item2.Users.FirstOrDefault(x => x.Id == tuple.Item2.BotId) as TLUser;
                Provider = tuple.Item2.Users.FirstOrDefault(x => x.Id == tuple.Item2.ProviderId) as TLUser;

                if (_paymentForm.HasSavedCredentials && _paymentForm.SavedCredentials is TLPaymentSavedCredentialsCard savedCard && _credentialsTitle == null)
                {
                    CredentialsTitle = savedCard.Title;
                }

                var amount = 0L;
                foreach (var price in _paymentForm.Invoice.Prices)
                {
                    amount += price.Amount;
                }

                if (_shipping != null)
                {
                    foreach (var price in _shipping.Prices)
                    {
                        amount += price.Amount;
                    }
                }

                TotalAmount = amount;

                _requestedInfo = tuple.Item4;
                _credentials   = tuple.Item7;
                _save          = tuple.Item8;
            }

            return(Task.CompletedTask);
        }
Exemplo n.º 4
0
 public static void NavigateToPaymentFormStep5(this INavigationService service, MessageViewModel message, PaymentForm paymentForm, TLPaymentRequestedInfo info, TLPaymentsValidatedRequestedInfo validatedInfo, TLShippingOption shipping, string title, string credentials, bool save)
 {
     service.Navigate(typeof(PaymentFormStep5Page), TLTuple.Create(message, paymentForm, info, validatedInfo, shipping, title ?? string.Empty, credentials ?? string.Empty, save));
 }
Exemplo n.º 5
0
 public static void NavigateToPaymentFormStep4(this INavigationService service, MessageViewModel message, PaymentForm paymentForm, TLPaymentRequestedInfo info, TLPaymentsValidatedRequestedInfo validatedInfo, TLShippingOption shipping)
 {
     service.Navigate(typeof(PaymentFormStep4Page), TLTuple.Create(message, paymentForm, info, validatedInfo, shipping));
 }