# BUYViewControllerDelegate Protocol Reference

Conforms to | NSObject
Declared in | BUYViewController.h

### `– controller:failedToCreateCheckout:`

This is called if there is an error in creating the BUYCheckout. These problems include not being connected to the Internet, or if there is a validation error in the checkout.

`- (void)controller:(BUYViewController *)controller failedToCreateCheckout:(NSError *)error`

#### Parameters

`controller` | The BUYViewController
`error` | An NSError describing the failure

#### Declared In

`BUYViewController.h`

### `– controllerFailedToStartApplePayProcess:`

This failure occurs when either the application is not properly configured to handle Apple Pay, or if the user does not have any credit cards configured in PassBook or cannot add any credit cards.

`- (void)controllerFailedToStartApplePayProcess:(BUYViewController *)controller`

#### Parameters

`controller` | The BUYViewController

#### Declared In

`BUYViewController.h`

### `– controller:failedToUpdateCheckout:withError:`

This failure occurs whenever an update to BUYCheckout fails (shipping address, billing address, etc.)

`- (void)controller:(BUYViewController *)controller failedToUpdateCheckout:(BUYCheckout *)checkout withError:(NSError *)error`

#### Parameters

`controller` | The BUYViewController
`checkout` | The BUYCheckout
`error` | An NSError describing the failure

#### Declared In

`BUYViewController.h`

### `– controller:failedToGetShippingRates:withError:`

This failure occurs when shipping rates cannot be retrieved.

`- (void)controller:(BUYViewController *)controller failedToGetShippingRates:(BUYCheckout *)checkout withError:(NSError *)error`

#### Parameters

`controller` | The BUYViewController
`checkout` | The BUYCheckout
`error` | An NSError describing the failure

#### Declared In

`BUYViewController.h`

### `– controller:failedToCompleteCheckout:withError:`

This failure occurs whenever completing a checkout fails. This can occur if there is missing payment information or if the shop is improperly configured.

`- (void)controller:(BUYViewController *)controller failedToCompleteCheckout:(BUYCheckout *)checkout withError:(NSError *)error`

#### Parameters

`controller` | The BUYViewController
`checkout` | The BUYCheckout
`error` | An NSError describing the failure

#### Declared In

`BUYViewController.h`

### `– controller:didCompleteCheckout:status:`

This is called whenever the checkout fully completes, success or failure.

`- (void)controller:(BUYViewController *)controller didCompleteCheckout:(BUYCheckout *)checkout status:(BUYStatus)status`

#### Parameters

`controller` | The BUYViewController
`checkout` | The BUYCheckout
`status` | Checkout status BUYStatus

#### Declared In

`BUYViewController.h`

### `– controller:didDismissApplePayControllerWithStatus:forCheckout:`

This is called when the Apple Pay Authorization View Controller has been dismissed. It will be called if the user cancels Apple Pay or the authorization was successful and the Apple Pay payment confirmation was shown to the user.

`- (void)controller:(BUYViewController *)controller didDismissApplePayControllerWithStatus:(PKPaymentAuthorizationStatus)status forCheckout:(BUYCheckout *)checkout`

#### Parameters

`controller` | The BUYViewController
`checkout` | The BUYCheckout

#### Discussion

Note: If the PKPaymentAuthorizationStatus is not PKPaymentAuthorizationStatusSuccess we will expire the checkout by calling `expireCheckout:completion:` to release the hold on the product inventory.

#### Declared In

`BUYViewController.h`

### `– controller:didDismissWebCheckout:`

This is called when the SFSafariViewController has been dismissed before checkout completion.

`- (void)controller:(BUYViewController *)controller didDismissWebCheckout:(BUYCheckout *)checkout`

#### Parameters

`controller` | The BUYViewController
`checkout` | The BUYCheckout

#### Declared In

`BUYViewController.h`

### `– didDismissViewController:`

The view controller has been dismissed

`- (void)didDismissViewController:(BUYViewController *)controller`

#### Parameters

`controller` | The BUYViewController

#### Declared In

`BUYViewController.h`

### `– controllerWillCheckoutViaWeb:`

Called when the user chooses to checkout via web checkout which will open Safari

`- (void)controllerWillCheckoutViaWeb:(BUYViewController *)viewController`

#### Parameters

`viewController` | the view controller

#### Declared In

`BUYViewController.h`

### `– controllerWillCheckoutViaApplePay:`

Called when the user chooses to checkout via Apple Pay

`- (void)controllerWillCheckoutViaApplePay:(BUYViewController *)viewController`

#### Parameters

`viewController` | the view controller

#### Declared In

`BUYViewController.h`