private async Task DemoNativeFlowWithProductAsync(Product product) { var cart = new Cart(); cart.AddVariant(product.Variants[0]); var checkout = new Checkout(cart); // Apply billing and shipping address, as well as email to the checkout checkout.ShippingAddress = Address; checkout.BillingAddress = Address; checkout.Email = "*****@*****.**"; client.UrlScheme = "xamarinsample://"; UIApplication.SharedApplication.NetworkActivityIndicatorVisible = true; try { checkout = await client.CreateCheckoutAsync(checkout); var shippingController = new ShippingRatesTableViewController(client, checkout); NavigationController.PushViewController(shippingController, true); } catch (NSErrorException ex) { Console.WriteLine("Error creating checkout: {0}", ex.Error); } UIApplication.SharedApplication.NetworkActivityIndicatorVisible = false; }
// Create a new checkout with the selected product. For convenience in the sample app we will hardcode the user's shipping address. // The shipping rates fetched in ShippingRateListActivity will be for this address. public async Task <Checkout> CreateCheckoutAsync(Product product) { var cart = new Cart(); cart.AddVariant(product.Variants[0]); Checkout = new Checkout(cart); Checkout.ShippingAddress = new Address { FirstName = "Dinosaur", LastName = "Banana", Address1 = "421 8th Ave", City = "New York", Province = "NY", Zip = "10001", CountryCode = "US" }; Checkout.Email = "*****@*****.**"; Checkout.SetWebReturnToUrl(GetString(Resource.String.web_return_to_url)); Checkout.SetWebReturnToLabel(GetString(Resource.String.web_return_to_label)); Checkout = await BuyClient.CreateCheckoutAsync(Checkout); return(Checkout); }