Book Image

Shopify Application Development

By : Michael Larkin
Book Image

Shopify Application Development

By: Michael Larkin

Overview of this book

Table of Contents (12 chapters)

Preface

Shopify has grown by leaps and bounds over the last few years and their ever expanding client list means that now is the perfect time to build a killer app to meet the needs of storeowners across the globe. With the release of the App Store, customers can read reviews, see screenshots, and install apps with a few clicks.

There has been a lot of effort from Shopify to make the developer experience as simple as possible. Free software libraries, extensive documentation, and a comprehensive API makes building and launching an app an enjoyable and lucrative process.

This book will teach you how to build an app starting with the setup of your local development environment, installing Ruby, and generating a basic Rails application.

Next, we'll go through several iterations as we build, refactor, and enhance our app, so that you get a feel of development best practices that are currently being used by software companies around the world. We'll wrap up monetizing the app using the Shopify Billing API, which is a simple and PCI-compliant way for us to charge users when they upgrade.

What this book covers

Chapter 1, Getting Started with Shopify, covers the basic functionality of Shopify and then explains the difference between private and public apps. A brief overview of the API and webhook systems is provided. The chapter then wraps up with a few thoughts on how to get started with building an app.

Chapter 2, Setting Up, focuses on setting up the reader's development environment, installing Ruby, Rails, and a few other requisite Gems. It shows us how to create a standard Rails site, update it with Twitter Bootstrap, and check it with source control. The chapter wraps up with instructions on how to deploy to Heroku for scalable web hosting.

Chapter 3, Building a Private App, covers the integration with Shopify's API in order to retrieve product and order information from the shop. The UI is then streamlined a bit before the logic to create a contest is created.

Chapter 4, Going Public, shows us how to refactor the existing app to support multiple Shopify accounts simultaneously. It then shows us how to hook into the installation process as well as how to subscribe and process webhooks.

Chapter 5, App Billing and Publication, completes the app by adding a free and paid plan and demonstrates how to setup a recurring charge via the Shopify Billing API. The chapter wraps up by explaining the process for publishing the app in the App Store so that the storeowners can install it automatically.

What you need for this book

You will need a computer capable of running Ruby and a text editor/IDE suitable for developing Rails. A Shopify and a Heroku account are required. It's recommended that an account with a source control service such as GitHub or Bitbucket be used for code management and back up.

Who this book is for

This book is highly suited for Ruby developers who are interested in creating apps for fun and profit. Familiarity with Shopify is helpful but not required. Developers familiar with other web languages should be able to follow but would benefit from a Ruby Primer before reading this book.

Basic command line skills (Windows or Linux) are required as well, but these will be given in a format that can be copied and pasted as needed.

Conventions

In this book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "To use Rails 4.0.0 with Heroku, we need to add the rails_12factor gem to the Gemfile so that we can precompile our assets."

A block of code is set as follows:

    def obscure_string(string, count)
        return string if count.blank?
        substring = string.slice(0..(-1 * count - 1))
        return string.gsub(substring, "*" * substring.length)
    end

When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:

resources :products do
  collection do
    get 'import'
  end
  resources :variants
end

Commands that need to be entered at the terminal / shell window are set as follows:

gem install rails -v 4.0.0 --no-ri --no-rdoc

New terms and important words are shown in bold. Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "You should see a Welcome aboard page that lists out some helpful tips as well as information about the application's configuration as shown in the following screenshot:".

Note

Warnings or important notes appear in a box like this.

Tip

Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of.

To send us general feedback, simply send an e-mail to , and mention the book title through the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors.

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com. If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly to you. Additionally, the complete source code for the application is available online at http://github.com/mikelarkin/contestapp.

Errata

Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you would report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting http://www.packtpub.com/support, selecting your book, clicking on the errata submission form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website, or added to any list of existing errata, under the Errata section of that title.

Piracy

Piracy of copyright material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors, and our ability to bring you valuable content.

Questions

You can contact us at if you are having a problem with any aspect of the book, and we will do our best to address it.