README.md 2.6 KB
Newer Older
1 2 3 4 5 6
# Mobile Buy SDK Advanced Sample App

The Advanced Sample App demonstrates how to perform several tasks related to creating a checkout.

- Fetch collections
- Fetch products
7
- Optionally present using the `ProductViewController`
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
- Create a checkout
- Apply shipping rate
- Apply gift cards and discounts
- Complete checkout via web view, native checkout implementation, and Apple Pay

### Getting started

First, add your shop domain, API key and Channel ID to the `CollectionListViewController.m` macros.

```objc
#define SHOP_DOMAIN @"<shop_domain>"
#define API_KEY @"<api_key>"
#define CHANNEL_ID @"<channel_id>"
```


### Overview

The Advanced Sample App demonstrates several tasks that can be performed using the Mobile Buy SDK.  Each task is broken up into seperate view controllers. Polling endpoints are represented as NSOperations which can easily be utilized in your own apps.

### Classes
#### View Controllers

###### `CollectionListViewController`
* Initializes the `BUYClient`
* Fetches collections and displays them in a list
* Optionally allows for fetch of the first product page

###### `ProductListViewController`
* Fetches the products and displays them in a list
38
* Can present a product using the `ProductViewController` and demo the theme settings on the controller, or
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
* Creates a checkout with the selected product and pushes to the `ShippingRatesTableViewController`

###### `ShippingRatesTableViewController`
* Fetches the shipping rates for the checkout using `GetShippingRatesOperation`
* Updates the checkout with the selected shipping rate and pushes to the `PreCheckoutViewController`

###### `PreCheckoutViewController`
* Displays a summary of the checkout
* Allows for discounts and gift cards to be added to the checkout

###### `CheckoutViewController`
* Displays a summary of the checkout
* Checkout using a credit card
* Web checkout using Safari
* Checkout using Apple Pay

#### `NSOperation`s

###### `GetShopOperation`
* `NSOperation` based class to fetch the shop object

###### `GetShippingRatesOperation`
* `NSOperation` based class to poll for shipping rates

###### `GetCompletionStatusOperation`
* `NSOperation` based class to poll for the checkout completion status

### Apple Pay

Apple Pay is implemented in the CheckoutViewController.  It utilizes the `BUYApplePayHelpers` class which acts as the delegate for the `PKPaymentAuthorizationViewController`.  Setting the `MerchantId` is required to use Apple Pay.  For more information about supporting Apple Pay in your app, please consult [https://docs.shopify.com/mobile-buy-sdk/ios/enable-apple-pay](https://docs.shopify.com/mobile-buy-sdk/ios/enable-apple-pay).