public async Task <bool> Show(XPayRequest request) { NSString[] paymentNetworks = new NSString[] { PKPaymentNetwork.MasterCard, PKPaymentNetwork.Visa }; if (!PKPaymentAuthorizationViewController.CanMakePayments || !PKPaymentAuthorizationViewController.CanMakePaymentsUsingNetworks(paymentNetworks)) { throw new NotSupportedException(); } List <PKPaymentSummaryItem> items = new List <PKPaymentSummaryItem>(); for (int i = 0; i < request.Items.Count; i++) { XPayRequestItem requestItem = request.Items[i]; items.Add(PKPaymentSummaryItem.Create(requestItem.Label, new NSDecimalNumber(requestItem.Amount.ToString()))); } // add the total PKPaymentSummaryItem by summing together all the amounts items.Add(PKPaymentSummaryItem.Create(request.PayTo ?? "Payee", new NSDecimalNumber(items.Sum(x => x.Amount.FloatValue).ToString()))); PKPaymentRequest paymentRequest = new PKPaymentRequest(); paymentRequest.PaymentSummaryItems = items.ToArray(); paymentRequest.MerchantIdentifier = request.MerchantIdentifier; paymentRequest.MerchantCapabilities = PKMerchantCapability.ThreeDS; paymentRequest.CountryCode = request.CountryCode; paymentRequest.CurrencyCode = request.CurrencyCode; paymentRequest.SupportedNetworks = paymentNetworks; this.paymentController = new PKPaymentAuthorizationViewController(paymentRequest); this.paymentController.Delegate = this; UIWindow window = UIApplication.SharedApplication.KeyWindow; UIViewController vc = window.RootViewController; while (vc.PresentedViewController != null) { vc = vc.PresentedViewController; } await vc.PresentViewControllerAsync(this.paymentController, true); return(true); }
public async Task <bool> Show(XPayRequest request) { WalletClass.WalletOptions walletOptions = new WalletClass.WalletOptions.Builder() .SetEnvironment(WalletConstants.EnvironmentTest) .Build(); GoogleApiClient client = new GoogleApiClient.Builder(AndroidApp.Application.Context) .AddApi(WalletClass.API) .Build(); BooleanResult boolResult = await WalletClass.Payments.IsReadyToPayAsync(client); if (!boolResult.Value) { throw new NotSupportedException(); } return(true); }