STPShippingAddressViewControllerDelegate

@protocol STPShippingAddressViewControllerDelegate <NSObject>

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

    Objective-C

    - (void)shippingAddressViewControllerDidCancel:
        (nonnull STPShippingAddressViewController *)addressViewController;

    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 the completion block with the error. Otherwise, call the completion 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

    Objective-C

    - (void)shippingAddressViewController:
                (nonnull STPShippingAddressViewController *)addressViewController
                          didEnterAddress:(nonnull STPAddress *)address
                               completion:
                                   (nonnull STPShippingMethodsCompletionBlock)
                                       completion;

    Swift

    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. - see: 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

    Objective-C

    - (void)shippingAddressViewController:
                (nonnull STPShippingAddressViewController *)addressViewController
                     didFinishWithAddress:(nonnull STPAddress *)address
                           shippingMethod:(nullable PKShippingMethod *)method;

    Swift

    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. - see: STPAddress

    method

    the shipping method that was selected.