void DidSelectShippingContact(PKPaymentAuthorizationViewController controller, PKContact contact, PKPaymentShippingAddressSelected completion) { // Create a shipping method. Shipping methods use PKShippingMethod, // which inherits from PKPaymentSummaryItem. It adds a detail property // you can use to specify information like estimated delivery time. var shipping = new PKShippingMethod { Label = "Standard Shipping", Amount = NSDecimalNumber.Zero, Detail = "Delivers within two working days" }; // Note that this is a contrived example. Because addresses can come from // many sources on iOS they may not always have the fields you want. // Your application should be sure to verify the address is correct, // and return the appropriate status. If the address failed to pass validation // you should return `InvalidShippingPostalAddress` instead of `Success`. var address = contact.PostalAddress; var requiresInternationalSurcharge = address.Country != "United States"; PKPaymentSummaryItem[] summaryItems = MakeSummaryItems(requiresInternationalSurcharge); completion(PKPaymentAuthorizationStatus.Success, new[] { shipping }, summaryItems); }
public void ShippingAddressViewControllerEnteredAddress(ShippingAddressViewController addressViewController, Address address, ShippingMethodsCompletionBlock completion) { var upsGround = new PKShippingMethod { Amount = new NSDecimalNumber(0), Label = "UPS Ground", Detail = "Arrives in 3-5 days", Identifier = "ups_ground", }; var upsWorldwide = new PKShippingMethod { Amount = new NSDecimalNumber(10.99), Label = "UPS Worldwide Express", Detail = "Arrives in 1-3 days", Identifier = "ups_worldwide", }; var fedEx = new PKShippingMethod { Amount = new NSDecimalNumber(5.99), Label = "FedEx", Detail = "Arrives tomorrow", Identifier = "fedex", }; DispatchQueue.MainQueue.DispatchAfter(new DispatchTime(DispatchTime.Now, new TimeSpan(0, 0, 0, 0, 600)), () => { if (address.Country == null || address.Country == "US") { completion(ShippingStatus.Valid, null, new PKShippingMethod[] { upsGround, fedEx }, fedEx); } else if (address.Country == "AQ") { var error = new NSError(new NSString("ShippingError"), 123, new NSDictionary(NSError.LocalizedDescriptionKey, new NSString("Invalid Shipping Address"), NSError.LocalizedFailureReasonErrorKey, new NSString("We can't ship to this country."))); completion(ShippingStatus.Invalid, error, null, null); } else { fedEx.Amount = new NSDecimalNumber(20.99); completion(ShippingStatus.Valid, null, new PKShippingMethod[] { upsWorldwide, fedEx }, fedEx); } }); }
public void ShippingAddressViewControllerFinished(ShippingAddressViewController addressViewController, Address address, PKShippingMethod method) { customerContext.UpdateCustomer(address, null); DismissViewController(true, null); }
void DidSelectShippingContact (PKPaymentAuthorizationViewController controller, PKContact contact, PKPaymentShippingAddressSelected completion) { // Create a shipping method. Shipping methods use PKShippingMethod, // which inherits from PKPaymentSummaryItem. It adds a detail property // you can use to specify information like estimated delivery time. var shipping = new PKShippingMethod { Label = "Standard Shipping", Amount = NSDecimalNumber.Zero, Detail = "Delivers within two working days" }; // Note that this is a contrived example. Because addresses can come from // many sources on iOS they may not always have the fields you want. // Your application should be sure to verify the address is correct, // and return the appropriate status. If the address failed to pass validation // you should return `InvalidShippingPostalAddress` instead of `Success`. var address = contact.PostalAddress; var requiresInternationalSurcharge = address.Country != "United States"; PKPaymentSummaryItem[] summaryItems = MakeSummaryItems (requiresInternationalSurcharge); completion (PKPaymentAuthorizationStatus.Success, new [] { shipping }, summaryItems); }