/mobile-buy-sdk-android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.

Primary LanguageJavaMIT LicenseMIT

Mobile Buy SDK

GitHub license Build status GitHub release

Mobile Buy SDK for Android

Shopify’s Mobile Buy SDK makes it simple to sell physical products inside your mobile app. With a few lines of code, you can connect your app with the Shopify platform and let your users buy your products using their credit card.

Documentation

Please find all documentation on the Mobile Buy SDK for Android page.

Requirements

  • ** Android SDK Level 14 (Ice Cream Sandwich 4.0) or higher **
  • ** JDK 1.7 **
  • Android studio 2.1.x or greater recommended
  • The Mobile App sales channel added to your Shopify store

Documentation

Getting Started and Integration Guide

Javadoc

Building the SDK

Clone this repo or download as .zip and import the build.gradle file into Android Studio.

The workspace includes the Mobile Buy SDK project and a sample app which demonstrates all of the features of the SDK.

Modules

The Mobile Buy SDK includes a two modules.

  • buy: This is the Mobile Buy SDK framework. This is an Android library project.
  • sample: This is an Android app module which demonstrates how to use the SDK.

Gradle Targets

There are a number of custom gradle targets defined in the buy module. These can be invoked on the command line with ./gradlew

  • javadoc - generates the javadoc for the project
  • javadocJar - generates the javadoc, and wraps it in a jar
  • archiveReleasePackage - builds the release buy release aar, javadoc, and bundles it all together in a zip file ready for distribution. The output will be in buy/build/distributions
  • bintrayUpload - publishes a new release to Bintray's jCenter repository (for Shopify internal use only).

Integration

The simplest way to use the Mobile Buy SDK in your project is to add the following jCenter dependency to your build.gradle file:

compile 'com.shopify.mobilebuysdk:buy:2.0.0'

The Integration Guide also contains step-by-step instructions and sample code for integrating the Mobile Buy SDK into your application. The sample module in the Android Studio project is also a great resource.

Running the Tests

There are two ways to run the integration tests in the SDK:

  1. With mocked network responses from a pre-defined shop.
  2. With live network responses from a shop of your choosing.

In either case, you will need to create a shop.properties file in the MobileBuy project directory with this format:

SHOP_DOMAIN=myshop.myshopify.com
API_KEY=0123456789abcdefghijklmnopqrstuvwxyz
CHANNEL_ID=2345678

DO NOT CHECK THE shop.properties FILE INTO GIT

You can start the tests by running the Tests in 'com.shopify.buy' target in Android Studio. You can also right-click on the buy module in the Project hierarchy and select Run -> Tests in 'buy'.

Testing with mocked network responses

The integration tests with the mocked network responses do not require any internet connection and run very quickly. To use this mode, simply remove the values from your shop.properties file:

SHOP_DOMAIN=
API_KEY=
APP_ID=

Testing with live network responses

To run the 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. Also, make sure that your shop.properties file has the correct credentials for your shop.

Some notes about test_shop_data.json:

  • The gift_cards array contains three valid gift cards, one expired gift card, and one invalid gift card. Make sure that the value field contains the correct dollar amount for each gift card.
  • The discounts array contains one expired discount code and one valid discount code. Make sure that the value field contains the correct dollar amount (or percentage amount) for each discount.

How Can I Contribute?

We welcome contributions. Follow the steps in the CONTRIBUTING file.

License

The Mobile Buy SDK is provided under an MIT Licence. See the LICENSE file.