private async void ValidateResponseCoordinationPaymentMethod(ResponseCoordinationPaymentMethod response) { dialogService.HideProgress(); if (response.Success) { PaymentMethods.Clear(); CoordinationPaymentMethod ExternalMethod = response.CoordinationPaymentMethods.Where(x => x.ExternalMethod).FirstOrDefault(); if (ExternalMethod != null) { ExternalMethod.IconApp = "pasarela"; ExternalMethod.PaymentMethodName = "Pago en línea"; ExternalMethod.PaymentMethodDescription = string.Empty; SetCoordination(ExternalMethod); } foreach (CoordinationPaymentMethod item in response.CoordinationPaymentMethods) { if (item.ExternalMethod == false) { SetCoordination(item); } } await navigationService.Navigate(AppPages.CoordinationPaymentMethodPage); } else { await dialogService.ShowMessage(response.Title, response.Message); } }
public async Task Refresh() { var selectedPaymentMethodId = PaymentMethods.FirstOrDefault(p => p.Selected)?.PaymentMethod.Id; PaymentMethods.Clear(); try { var stripeClient = await EphemeralService.Instance.GetClient(); var customerId = await EphemeralService.Instance.GetCustomerId(); var customerService = new CustomerService(stripeClient); _customer = await customerService.GetAsync(customerId); var paymentMethodService = new PaymentMethodService(stripeClient); var paymentMethodListOptions = new PaymentMethodListOptions { Customer = _customer.Id, Type = "card" }; var methods = await paymentMethodService.ListAsync(paymentMethodListOptions); foreach (var paymentMethod in methods) { PaymentMethods.Add(new PaymentMethodViewModel(paymentMethod, PaymentMethodSelected)); } if (PaymentMethods.Any()) { var toSelect = PaymentMethods.FirstOrDefault(pm => pm.PaymentMethod.Id == selectedPaymentMethodId) ?? PaymentMethods.First(); SelectPaymentMethod(toSelect); } } catch (Exception ex) { await Navigator.ShowMessage("Error", ex.Message); } }