Exemplo n.º 1
0
        private async void SendExecute()
        {
            var disclaimer = await TLMessageDialog.ShowAsync(string.Format(Strings.Resources.PaymentWarningText, _bot.FullName, _provider.FullName), Strings.Resources.PaymentWarning, Strings.Resources.OK);

            var confirm = await TLMessageDialog.ShowAsync(string.Format(Strings.Resources.PaymentTransactionMessage, Locale.FormatCurrency(_totalAmount, _paymentForm.Invoice.Currency), _bot.FullName, _invoice.Title), Strings.Resources.PaymentTransactionReview, Strings.Resources.OK, Strings.Resources.Cancel);

            if (confirm != Windows.UI.Xaml.Controls.ContentDialogResult.Primary)
            {
                return;
            }

            IsLoading = true;

            TLInputPaymentCredentialsBase credentials;

            if (_paymentForm.HasSavedCredentials && _paymentForm.SavedCredentials is TLPaymentSavedCredentialsCard savedCard)
            {
                credentials = new TLInputPaymentCredentialsSaved {
                    Id = savedCard.Id, TmpPassword = ApplicationSettings.Current.TmpPassword.TmpPassword
                };
            }
            else
            {
                credentials = new TLInputPaymentCredentials {
                    Data = new TLDataJSON {
                        Data = _credentials
                    }, IsSave = _save
                };
            }

            var response = await LegacyService.SendPaymentFormAsync(_message.Id, _requestedInfo?.Id, _shipping?.Id, credentials);

            if (response.IsSucceeded)
            {
                if (response.Result is TLPaymentsPaymentVerficationNeeded verificationNeeded)
                {
                    if (Uri.TryCreate(verificationNeeded.Url, UriKind.Absolute, out Uri uri))
                    {
                        await Launcher.LaunchUriAsync(uri);
                    }
                }

                NavigationService.GoBackAt(1);
            }
            else if (response.Error != null)
            {
            }
        }