Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
README Updates (#437)
Browse files Browse the repository at this point in the history
* Added links from README.md to EXAMPLES.md

* Moved build targets to README.md

* Moved examples above supported platforms

* Adding some styling to README.md

* Made table of contents directly link to EXAMPLES.md
  • Loading branch information
mikkoh committed Dec 21, 2017
1 parent 4c122fc commit 0a40b67
Show file tree
Hide file tree
Showing 3 changed files with 78 additions and 48 deletions.
16 changes: 0 additions & 16 deletions BUILDTARGETS.md

This file was deleted.

68 changes: 50 additions & 18 deletions EXAMPLES.md
Expand Up @@ -12,21 +12,25 @@ The Shopify SDK for Unity queries Shopify's [Storefront API](https://help.shopif
- [Query Products](#query-products)
- [Query Collections](#query-collections)
- [Build a cart](#build-a-cart)
- [Web view checkout](#web-view-checkout)
- [Native pay checkout (Apple Pay / Android Pay)](#native-pay-checkout)
- [Build a cart based on selected options](#build-a-cart-based-on-selected-options)
- [Checkout with a checkout link](#checkout-with-a-checkout-link)
- [Checkout with a Web View](#checkout-with-a-web-view)
- [Checkout with Native Pay (Apple Pay / Android Pay)](#checkout-with-native-pay-apple-pay--android-pay)
- [Custom queries](#custom-queries)

## Before you begin

Before you can start using the Shopify SDK for Unity, you need:

- a Shopify store with at least one product
- a Shopify store with at least one product. If you do not have a Shopify store you have two options:
+ [Sign up as a Shopify Partner to create a test store](https://www.shopify.ca/partners)
+ Start testing the SDK using our test store. (domain and access token listed below)
- [a storefront access token for your app](https://help.shopify.com/api/storefront-api/getting-started#obtaining-a-storefront-access-token)
- [to install the Shopify SDK for Unity into your Unity project](README.md#using-the-unity-buy-sdk-in-unity)

## Supported build targets

See [Build Target Requirements](BUILDTARGETS.md) for information on setting up the SDK on iOS and Android
See [Build Target Requirements](README.md#supported-build-targets) for information on setting up the SDK on iOS and Android

## Initialize the SDK

Expand Down Expand Up @@ -181,7 +185,7 @@ void Start () {
// In this case, the cart will have 3 copies of the variant.
cart.LineItems.AddOrUpdate(firstProductFirstVariant, 3);

// The following will output the variant id which was selected by the above options
// The following will output the variant id which was setup using the first product variant
Debug.Log("First line item's variant id is: " + cart.LineItems.All()[0].VariantId);
});
}
Expand All @@ -203,7 +207,7 @@ To get a line item do the following:
LineItemInput lineItem = cart.LineItems.Get(firstProductFirstVariant);
```

### Cart line items based on selected options
### Build a cart based on selected options

In Shopify, a product can have many options. These options map to **variants** of a product. The following example shows how to create line items in a cart based on selected product variants:

Expand Down Expand Up @@ -247,7 +251,42 @@ void Start () {
// Create a line item based on the selected options for a product
cart.LineItems.AddOrUpdate(firstProduct, selectedOptions, 1);

// Checkout the selected product
// The following will output the variant id which was selected by the above options
Debug.Log("First line item's variant id is: " + cart.LineItems.All()[0].VariantId);
});
}
```

If you want to `Delete` or `Get` a line item, then use the following:

```cs
cart.LineItems.Get(firstProduct, selectedOptions);
cart.LineItems.Delete(firstProduct, selectedOptions);
```

## Checkout with a checkout link

```cs
using Shopify.Unity;
using Shopify.Unity.SDK;

void Start () {
string accessToken = "b8d417759a62f7b342f3735dbe86b322";
string shopDomain = "unity-buy-sdk.myshopify.com";

ShopifyBuy.Init(accessToken, shopDomain);

ShopifyBuy.Client().products((products, error, after) => {
Cart cart = ShopifyBuy.Client().Cart();

List<ProductVariant> firstProductVariants = (List<ProductVariant>) products[0].variants();
ProductVariant firstProductFirstVariant = firstProductVariants[0];

// The following example adds a line item using the first products first variant.
// In this case, the cart will have 3 copies of the variant.
cart.LineItems.AddOrUpdate(firstProductFirstVariant, 3);

// Checkout with the url in the Device Browser
cart.GetWebCheckoutLink(
success: (link) => {
Application.OpenURL(link);
Expand All @@ -260,14 +299,7 @@ void Start () {
}
```

If you want to `Delete` or `Get` a line item, then use the following:

```cs
cart.LineItems.Get(firstProduct, selectedOptions);
cart.LineItems.Delete(firstProduct, selectedOptions);
```

## Web view checkout
## Checkout with a Web View

After creating an instance of `Cart` and adding items to it, you can use the `CheckoutWithWebView` method to
start a web view that contains the checkout for the cart.
Expand Down Expand Up @@ -306,11 +338,11 @@ ShopifyBuy.Client().products((products, error, after) => {
});
```

## Native pay checkout
## Checkout with Native Pay (Apple Pay / Android Pay)

You can allow users to pay with native pay (Apple Pay or Android Pay, depending on the device OS), providing a seamless checkout experience.
You can allow users to pay with Apple Pay or Android Pay (coming soon), depending on the device OS, providing a seamless checkout experience.

To determine whether the user is able to make a payment with native pay, you can use the `CanCheckoutWithNativePay` method. If the user has this capability, then you can use `CheckoutWithNativePay` to present the native pay authentication interface to the user. If they do not, then you can accept payment using [Web View Checkout](#web-view-checkout).
To determine whether the user is able to make a payment with Native Pay, you can use the `CanCheckoutWithNativePay` method. If the user has this capability, then you can use `CheckoutWithNativePay` to present the native pay authentication interface to the user. If they do not, then you can accept payment using [Web View Checkout](#checkout-with-a-web-view).

`CheckoutWithNativePay` takes in 4 parameters:

Expand Down
42 changes: 28 additions & 14 deletions README.md
Expand Up @@ -8,23 +8,24 @@ The Shopify SDK for Unity allows Unity developers to query and sell products fro

- [Features](#features)
- [Documentation](#documentation)
- [Using the Shopify SDK for Unity in Unity](#using-the-shopify-sdk-for-unity-in-unity)
- [Using the Shopify SDK for Unity](#using-the-shopify-sdk-for-unity)
- [Examples](EXAMPLES.md)
- [Supported build targets](#supported-build-targets)
- [Examples](#examples)

## Features

- Query products
- Query collections
- Create a cart
- Check out via weblink
- Checkouts via Apple Pay and Safari Web View
- Checkouts via Android Chrome Custom Tab
- Make custom GraphQL queries using the [Storefront API](https://help.shopify.com/api/storefront-api)
- [Query products](EXAMPLES.md#query-products)
- [Query collections](EXAMPLES.md#query-collections)
- [Build a cart](EXAMPLES.md#build-a-cart)
- [Check out via weblink](EXAMPLES.md#checkout-with-a-checkout-link)
- [Checkouts via Safari Web View](EXAMPLES.md#checkout-with-a-web-view)
- [Checkouts via Apple Pay](EXAMPLES.md#checkout-with-native-pay-apple-pay--android-pay)
- [Checkouts via Android Chrome Custom Tab](EXAMPLES.md#checkout-with-a-web-view)
- [Make custom GraphQL queries using the Storefront API](EXAMPLES.md#custom-queries)

Coming Soon:

- Checkouts via Android Pay
- [Checkouts via Android Pay](EXAMPLES.md#checkout-with-native-pay-apple-pay--android-pay)

## Documentation

Expand All @@ -35,7 +36,7 @@ Coming Soon:
- [How to contribute](CONTRIBUTING.md)
- [How to Test](TESTING.md)

## Using the Shopify SDK for Unity in Unity
## Using the Shopify SDK for Unity

By following the steps below you'll install the Shopify SDK for Unity into your Unity project using the [shopify-buy.unitypackage](https://github.com/Shopify/unity-buy-sdk/raw/master/shopify-buy.unitypackage):

Expand All @@ -45,10 +46,23 @@ By following the steps below you'll install the Shopify SDK for Unity into your

When you are ready to build for a specific platform, please read the [Supported build targets](#supported-build-targets) section to know how to configure your `Player Settings` and `Build Settings` in Unity

## Supported build targets
See [Build Target Requirements](BUILDTARGETS.md) for supported target platforms and requirements.

## Examples
Checkout our [Example Guide](EXAMPLES.md).

## Supported build targets

The Shopify SDK for Unity should work on all platforms which support Unity's `Application.OpenURL`. However we've made it much easier for users to checkout on iOS and Android. Below we list out more details about each of these platforms

### iOS

> The Shopify SDK for Unity requires iOS applications to be built using the Xcode 9 and above, have a minimum target SDK of iOS 9 and support Swift 3.
To target iOS see the [iOS Build Details](BUILDDETAILS.md#ios)

### Android

> The Shopify SDK for Unity requires Android applications to have a minimum API level of Android 4.4 'Kit Kat' (API Level 19).
To target Android see the [Android Build Details](BUILDDETAILS.md#android)

<img src="https://cdn.shopify.com/shopify-marketing_assets/builds/19.0.0/shopify-full-color-black.svg" width="200" />

0 comments on commit 0a40b67

Please sign in to comment.