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.
Please find all documentation on the Mobile Buy SDK for Android page.
- ** 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
Getting Started and Integration Guide
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.
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.
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 projectjavadocJar
- generates the javadoc, and wraps it in a jararchiveReleasePackage
- builds the releasebuy
release aar, javadoc, and bundles it all together in a zip file ready for distribution. The output will be in buy/build/distributionsbintrayUpload
- publishes a new release to Bintray's jCenter repository (for Shopify internal use only).
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.
There are two ways to run the integration tests in the SDK:
- With mocked network responses from a pre-defined shop.
- 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'.
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=
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 thevalue
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 thevalue
field contains the correct dollar amount (or percentage amount) for each discount.
We welcome contributions. Follow the steps in the CONTRIBUTING file.
The Mobile Buy SDK is provided under an MIT Licence. See the LICENSE file.