STPShippingAddressViewControllerDelegate
@objc
public protocol STPShippingAddressViewControllerDelegate : NSObjectProtocol
An STPShippingAddressViewControllerDelegate
is notified when an STPShippingAddressViewController
receives an address, completes with an address, or is cancelled.
-
Called when the user cancels entering a shipping address. You should dismiss (or pop) the view controller at this point.
Declaration
Swift
func shippingAddressViewControllerDidCancel( _ addressViewController: STPShippingAddressViewController)
Parameters
addressViewController
the view controller that has been cancelled
-
This is called when the user enters a shipping address and taps next. You should validate the address and determine what shipping methods are available, and call the
completion
block when finished. If an error occurrs, call thecompletion
block with the error. Otherwise, call thecompletion
block with a nil error and an array of available shipping methods. If you don’t need to collect a shipping method, you may pass an empty array or nil.Declaration
Swift
@objc(shippingAddressViewController:didEnterAddress:completion:) func shippingAddressViewController( _ addressViewController: STPShippingAddressViewController, didEnter address: STPAddress, completion: @escaping STPShippingMethodsCompletionBlock )
Parameters
addressViewController
the view controller where the address was entered
address
the address that was entered. - seealso: STPAddress
completion
call this callback when you’re done validating the address and determining available shipping methods.
-
This is called when the user selects a shipping method. If no shipping methods are given, or if the shipping type doesn’t require a shipping method, this will be called after the user has a shipping address and your validation has succeeded. After updating your app with the user’s shipping info, you should dismiss (or pop) the view controller. Note that if
shippingMethod
is non-nil, there will be an additional shipping methods view controller on the navigation controller’s stack.Declaration
Swift
@objc(shippingAddressViewController:didFinishWithAddress:shippingMethod:) func shippingAddressViewController( _ addressViewController: STPShippingAddressViewController, didFinishWith address: STPAddress, shippingMethod method: PKShippingMethod? )
Parameters
addressViewController
the view controller where the address was entered
address
the address that was entered. - seealso: STPAddress
method
the shipping method that was selected.