The Advanced Sample App demonstrates how to perform several tasks related to creating a checkout.
- Fetch collections
- Fetch products
- Optionally present using the `BUYProductViewController`
- 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
* Can present a product using the `BUYProductViewController` and demo the theme settings on the controller, or
* 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).
The web sample app demonstrates how you can load your shop's website in a webview, and support Apple Pay.
### Getting started
First, add your shop domain, API key and Channel ID to the `AppDelegate.h` macros.
```objc
#define SHOP_DOMAIN @"<shop_domain>"
#define API_KEY @"<api_key>"
#define CHANNEL_ID @"<channel_id>"
```
To support Apple Pay, add your Merchant ID as well.
```objc
#define MERCHANT_ID @"<merchant_id>"
```
### Overview
The sample app instantiates a view controller which is a subclass of `BUYStoreViewController`. This displays a webview with your shop, but intercepts the checkout to support Apple Pay.
The sample app also demonstrates how to use the `BUYClient` to obtain shop details by calling `getShop:`
@@ -16,15 +16,18 @@ Please find all documentation on the [Mobile Buy SDK for iOS page](https://docs.
...
@@ -16,15 +16,18 @@ Please find all documentation on the [Mobile Buy SDK for iOS page](https://docs.
### Installation
### Installation
#### Manual Installation (Project)
<ahref="../../releases/latest">Download the latest version</a>
<ahref="../../releases/latest">Download the latest version</a>
#### Dynamic Framework Installation
1. Drag the `Mobile Buy SDK.xcodeproj` into your existing project
1. Drag the `Mobile Buy SDK.xcodeproj` into your existing project
2. Add the `Buy` target as a `Target Dependancy` in the `Build Phases` of your project's target
2. Add the `Buy` target as a `Target Dependancy` in the `Build Phases` of your project's target
3. Add the `Buy` target in the `Link Binary with Libraries` section in `Build Phases`
3. Add the `Buy` (second target on the list is the Dynamic framework) target in the `Embedded Binaries` section in `Build Phases`
See the [Sample Apps](/Mobile Buy SDK Sample Apps/) for an example of Dynamic Framework usage.
#### Manual Installation (Framework)
#### Static Framework Installation
If you would like to not include the Mobile Buy SDK Project within your existing project, you can link directly to the `Buy.framework`.
If you would like to not include the Mobile Buy SDK Project within your existing project, you can link directly to the `Buy.framework`.
...
@@ -42,6 +45,12 @@ pod "Mobile-Buy-SDK"
...
@@ -42,6 +45,12 @@ pod "Mobile-Buy-SDK"
Then run `pod install`
Then run `pod install`
Then run `pod install`
```objc
#import "Buy.h"
```
#### Carthage
#### Carthage
Add the following line to your Cartfile
Add the following line to your Cartfile
...
@@ -92,9 +101,11 @@ The workspace includes the Mobile Buy SDK project and the sample app projects. T
...
@@ -92,9 +101,11 @@ The workspace includes the Mobile Buy SDK project and the sample app projects. T
The Mobile Buy SDK includes a number of targets and schemes:
The Mobile Buy SDK includes a number of targets and schemes:
***Buy**: This is the Mobile Buy SDK framework. This build is based on the current build configuration. To build a universal framework that can run on a device and on the Simulator and to be included in your app, please refer to the `Universal Framework` target below
***Buy**: This is the Mobile Buy SDK static framework. This build is based on the current build configuration. To build a universal framework that can run on a device and on the Simulator and to be included in your app, please refer to the `Universal Framework` target below
***Universal Framework**: This builds the framework using `build_universal.sh` script in the `Universal Framework` target and copies the built framework in the `/Mobile Buy SDK Sample Apps` folder. Build this target if you have made any changes to the framework that you want to test with the sample apps as the sample apps do not build the framework directly but embed the already built framework
***Buy Dynamic**: This is the Mobile Buy SDK dynamic framework. Please refer to the installation section above.
***Universal Framework**: This builds a static framework using `build_universal.sh` script in the `Universal Framework` target and copies the built framework in the `/Mobile Buy SDK Sample Apps` folder. Build this target if you have made any changes to the framework that you want to test with the sample apps as the sample apps do not build the framework directly but embed the already built framework
***Mobile Buy SDK Tests**: Tests for the Mobile Buy SDK framework. See instructions below
***Mobile Buy SDK Tests**: Tests for the Mobile Buy SDK framework. See instructions below
...
@@ -102,6 +113,16 @@ The Mobile Buy SDK includes a number of targets and schemes:
...
@@ -102,6 +113,16 @@ The Mobile Buy SDK includes a number of targets and schemes:
***Playground**: This target is a basic app that depends directly on the `Buy` framework target and builds the framework every time using the `Playground` app's build configuration. You may use this app and target to play around with the SDK. Be sure not to check in any changes you may have made in files related to this app
***Playground**: This target is a basic app that depends directly on the `Buy` framework target and builds the framework every time using the `Playground` app's build configuration. You may use this app and target to play around with the SDK. Be sure not to check in any changes you may have made in files related to this app
### Sample Apps
The repo includes 3 sample apps. Each sample apps embeds the dynamic framework and includes readme files with more information:
We suggest you take a look at the **Advanced Sample App** and test your shop with the sample app before you begin. If you run into any issues, the **Advanced Sample App** is also a great resource for debugging integration issues and checkout.
### Unit Tests
### Unit Tests
To run the Mobile Buy SDK integration tests against an actual shop, you will need a Shopify shop that is publicly accessible (not password protected). Please note that the integration tests **will create an order** on that shop. This is to validate that the SDK works properly with Shopify. Modify the **test_shop_data.json** file to contain your shop's credentials and the required product IDs, gift cards, and discounts as necessary.
To run the Mobile Buy SDK integration tests against an actual shop, you will need a Shopify shop that is publicly accessible (not password protected). Please note that the integration tests **will create an order** on that shop. This is to validate that the SDK works properly with Shopify. Modify the **test_shop_data.json** file to contain your shop's credentials and the required product IDs, gift cards, and discounts as necessary.