BUYViewController Class Reference

Inherits from UIViewController
Conforms to PKPaymentAuthorizationViewControllerDelegate
Declared in BUYViewController.h

Overview

This base class guides you through the entire Apple Pay process.

  delegate

Register yourself as a BUYViewControllerDelegate to handle all errors, and status changes.

@property (nonatomic, weak) id<BUYViewControllerDelegate> delegate

Declared In

BUYViewController.h

  client

Set the BUYClient using the provided initializer method initWithClient: or if using Storyboards, override after Storyboard initialization.

@property (nonatomic, strong) BUYClient *client

Declared In

BUYViewController.h

  shop

The associated shop. setting this prior to displaying will prevent another network request

@property (nonatomic, strong) BUYShop *shop

Declared In

BUYViewController.h

  merchantId

The merchant ID used for Apple Pay

@property (nonatomic, strong) NSString *merchantId

Declared In

BUYViewController.h

  isApplePayAvailable

Returns YES if the following conditions are met: - the device hardware is capable of using Apple Pay - the device has a payment card setup - the merchant ID has been set to use Apple Pay

@property (nonatomic, assign, readonly) BOOL isApplePayAvailable

Declared In

BUYViewController.h

  allowApplePaySetup

If the merchantId is set and the device support Apple Pay but no credit card is present this allows the user to add a payment pass to the Wallet. The user is given the option to add a payment pass or continue with web checkout. Default is set to true. The Set Up Apple Pay button will, however still only show if [PKAddPaymentPassViewController canAddPaymentPass] returns true, merchantId is set and the app is running iOS 9.0 and above.

@property (nonatomic, assign) BOOL allowApplePaySetup

Declared In

BUYViewController.h

– canShowApplePaySetup

Whether the device is setup to show the Apple Pay setup sheet. allowApplePaySetup must be set to YES, and the merchantId must also be set in addition to the device settings for this method to return YES.

- (BOOL)canShowApplePaySetup

Return Value

YES if the Setup Apple Pay button should be shown

Declared In

BUYViewController.h

– shouldShowApplePayButton

Returns whether the Apple Pay button should be shown

- (BOOL)shouldShowApplePayButton

Return Value

YES if isApplePayAvailable or canShowApplePaySetup returns YES

Declared In

BUYViewController.h

– shouldShowApplePaySetup

Returns whether to show the Apple Pay setup button in place of the Apple Pay buy button

- (BOOL)shouldShowApplePaySetup

Return Value

YES if isApplePayAvailable returns NO and canShowApplePaySetup returns YES

Declared In

BUYViewController.h

  checkout

The current checkout object

@property (nonatomic, strong, readonly) BUYCheckout *checkout

Declared In

BUYViewController.h

– loadShopWithCallback:

Loads the shop details

- (void)loadShopWithCallback:(void ( ^ ) ( BOOL , NSError *))block

Parameters

block

callback block called on completion

Declared In

BUYViewController.h

  supportedNetworks

The supported credit card payment networks. iOS 8.3: PKPaymentNetworkAmex, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa. iOS 9.0: PKPaymentNetworkAmex, PKPaymentNetworkDiscover, PKPaymentNetworkMasterCard, PKPaymentNetworkVisa.

@property (nonatomic, copy) NSArray *supportedNetworks

Declared In

BUYViewController.h

– paymentRequest

Override point to return a custom payment request

- (PKPaymentRequest *)paymentRequest

Return Value

a new payment request object

Discussion

The default merchantCapability is PKMerchantCapability3DS

Declared In

BUYViewController.h

– initWithClient:

Creates a BUYViewController using your

- (instancetype)initWithClient:(BUYClient *)client

Parameters

client

A BUYClient configured to your shop

Return Value

A BUYViewController

Declared In

BUYViewController.h

– startApplePayCheckout:

Start an Apple Pay checkout with a BUYCheckout object. The checkout object will be created or updated on Shopify before proceeding with the Apple Pay checkout

- (void)startApplePayCheckout:(BUYCheckout *)checkout

Parameters

checkout

A BUYCheckout object to start an Apple Pay checkout with

Declared In

BUYViewController.h

– startWebCheckout:

Start a responsive web checkout with a BUYCheckout object. This call will jump out to Safari and the shop’s responsive web checkout. The checkout object will be created or updated on Shopify before proceeding with the responsive web checkout

- (void)startWebCheckout:(BUYCheckout *)checkout

Parameters

checkout

A BUYCheckout object to start a web checkout with

Declared In

BUYViewController.h

– startCheckoutWithCartToken:

Creates a checkout using a web cart’s token. This is useful when handing off the cart from a WKWebView to an Apple Pay checkout.

- (void)startCheckoutWithCartToken:(NSString *)token

Parameters

token

Cart token from your Shopify store’s storefront

Declared In

BUYViewController.h

– checkoutCompleted:status:

Override this method if you want to perform any actions before information the delegate

- (void)checkoutCompleted:(BUYCheckout *)checkout status:(BUYStatus)status

Parameters

checkout

The completed BUYCheckout

status

The status of the BUYCheckout

Declared In

BUYViewController.h

+ completeCheckoutFromLaunchURL:

Call this method from the application delegate method openURL:sourceApplication:annotation when returning from a web checkout

+ (void)completeCheckoutFromLaunchURL:(NSURL *)url

Parameters

url

the NSURL passed in to the app delegate

Declared In

BUYViewController.h