private async Task OnSaveCommandExecute() { if (IsBusy) { return; } IsBusy = true; try { Int64 orderId = await IdService.CreateOrderIdAsync(); User user = await UserService.GetUserAsync(Helpers.DeviceHelper.GetMunchyId()); Card card = await CreditCardService.CreateCreditCard(); card = await CreditCardService.AuthorizeCreditCard(card.id.ToString(), "1000000000000008", "2112", 123); Subscription subscription = await SubscriptionService.CreateSubscription(orderId); CardDetails cardDetails = await CreditCardService.CreateCreditCardToken(card.id.ToString()); Subscription authSub = await SubscriptionService.AuthorizeSubscription(subscription.id.ToString(), 1000, cardDetails.token); authSub = await SubscriptionService.GetSubscription(authSub.id.ToString()); if (authSub.accepted) { SimpleCreditCard creditCard = new SimpleCreditCard(card.metadata.brand.ToString(), card.metadata.exp_year.ToString(), card.metadata.exp_month.ToString(), "XXXX XXXX XXXX " + card.metadata.last4); await this.UserService.CreateUserCreditCard(user.Id, creditCard); await Application.Current.MainPage.Navigation.PushAsync(new CreatePaymentAuthenticationPage(authSub.id.ToString())); } } catch (Exception e) { await Application.Current.MainPage.DisplayAlert("Fejl!", e.ToString(), "OK"); } finally { IsBusy = false; } }
private async void PayWithFingerPrint(bool captureNow) { IsBusy = true; var result = await CrossFingerprint.Current.AuthenticateAsync("Scan for at betale"); if (result.Authenticated) { IsBusy = true; Int64 order_id = await IdService.CreateOrderIdAsync(); Payment payment = await PaymentService.CreateRecurringPayment(user.SubId, captureNow, order_id); payment = await PaymentService.GetPayment(payment.id.ToString()); if (payment.accepted) { IsBusy = true; Order order = await OrderService.CreateOrder(BasketService.CurrentBasket, payment); Reciept reciept = await RecieptService.AddRecieptAsync(order, Helpers.DeviceHelper.GetMunchyId()); BasketService.CurrentBasket.ClearBasketItems(); if (captureNow) { Page page = Application.Current.MainPage; await page.Navigation.PushAsync(new SuccesPage("Betalingen er nu gennemført", new ScanQRPage(reciept))); Application.Current.MainPage.Navigation.RemovePage(Application.Current.MainPage.Navigation.NavigationStack[1]); } else { Page page = Application.Current.MainPage; await page.Navigation.PushAsync(new SuccesPage("Betalingen er nu gennemført", Application.Current.MainPage.Navigation.NavigationStack[0])); Application.Current.MainPage.Navigation.RemovePage(Application.Current.MainPage.Navigation.NavigationStack[0]); } } } IsBusy = false; }