Preface

How We Do Commerce

The way in which we do commerce across the globe has changed greatly in the last decade, and indeed in just the last couple of years. No longer can commerce be thought of as solely completed in brick-and-mortar storefronts and on PCs, through online commerce sites. We now have commerce anywhere and everywhere, through mobile devices and card readers that plug into our smartphones. Business models have expanded past the “freemium” and premium models used extensively online into innovative concepts such as social commerce and “causium” implementations. The commerce lifecycle is literally changing before our eyes.

On a recent trip to San Francisco, I found myself in one of the on-demand car service options traveling from my hotel across town to the Moscone conference center. While riding along, I realized that I had forgotten to purchase a birthday present for a friend. Using my smartphone, I looked up my friend’s wish list on a popular online shopping site and purchased a present to be shipped out that day in a few simple clicks. The site let me sign in quickly via my mobile device, find my friend’s wish list, see what was recommended for her, and check out without even having to pull out my credit card. I then remembered that the night before another friend had paid for dinner and I wanted to reimburse him for my half. So I opened my PayPal app on the phone and quickly transferred some funds to him.

In that short ride, I had completed multiple commerce transactions. When we arrived at the conference center, I handed my credit card to the driver, who took out his smartphone and plugged in a tiny card reader. He proceeded to swipe my credit card, input the total, and have me sign, and then emailed me a receipt.

The point of this story is that commerce is not only happening anywhere and at any time due to an explosion of smartphone usage, but customers are being introduced to a new level of convenience and features that are quickly becoming the expected level of service. Multiple models support these features, including ecommerce, mobile commerce (mcommerce), and social commerce (scommerce). Who knows what the next “initial-commerce” model will be? eBay has recognized this explosion of new models and established the X.commerce initiative, aimed at supporting the commerce models currently being used and ones yet to be invented. Many of the examples in this text leverage the knowledge and code of the X.com website, and it is a recommended source if you plan to be heavily involved in this area.

Even if you are familiar with the basic use cases of the various eBay APIs, you may not have leveraged any of the many other API sets from other eBay properties to tap into the greater commerce lifecycle. In this book, you will be able explore functional examples that can be applied to generate more demand, traffic, and sales. The examples are designed so that you can jump in feet first and skip the rudimentary details that you may already be familiar with. If you are not familiar with a particular API being used, the example will discuss the basic concepts while providing links to further online documentation and examples. By the end of the book the examples will have covered a wide range of real-life scenarios, showing you how to incorporate into your commerce model features and functionality from APIs including eBay, Hunch, Magento, Milo, PayPal, RedLaser, and ql.io.

The goal of this book is to show how, with a little bit of effort and a wealth of powerful APIs, you can create and enhance your commerce flows. The real-life technical examples cover a range of exciting and innovative uses of the APIs, from generating social recommendations using Twitter feeds to sharing products with friends by scanning QR codes with the RedLaser API. The examples are designed to take you past the basic transaction steps and into functional areas that create a strong commerce lifecycle, combining business strategy with technical solutions.

Creating a Lifecycle

Generally speaking, the focus of any business is to implement an easy-to-use transaction payment system for goods or services so that customers can pay for what they want quickly and efficiently. The premise of this cookbook is that commerce in any form—online, mobile, social, or even storefront—should not just be based on a single event in which a customer purchases an item, but instead should be enveloped in a lifecycle that encompasses the purchase transaction as a single step. The lifecycle starts before a customer ever reaches the point of purchase and can continue long past this event. Like an engine that turns over and over to keep a vehicle moving forward, the lifecycle should not stop after the single stroke of a purchase, but rather should optimally create the opportunity for multiple recurring purchases. As the lifecycle matures, the processes and stages that support the cycle become more robust and easier to accomplish.

Figure 1 shows a simplified commerce lifecycle, which is the basis for the structure of this book. The commerce lifecycle can be more complex, with more steps and sub-steps, but simplifying the lifecycle allows us to focus on the technology that can enhance these core steps or stages.

Simplified commerce lifecycle

Figure 1. Simplified commerce lifecycle

The simplified commerce lifecycle is composed of five steps:

  1. Product discovery and research

  2. Product presentation

  3. Purchase through a payment transaction

  4. Order fulfillment (shipment and receipt)

  5. Consumption and sharing through social commerce

Each step of the simplified lifecycle will be the basis for a chapter of examples in this book. Ultimately, all stages carry equal weight in their opportunity to create long-term customer relationships.

The first stage—product discovery—represents the time and effort that the customer puts into researching, discovering, and identifying a particular offering. Many different sources of knowledge can contribute to this discovery: the user may look at recommendations of similar items, check out local sources of products, or read product reviews. The goal of this stage is to provide the information and data necessary for the user to hone in on a product that she may have sought outright or discovered accidentally.

After the identification of the product in the product discovery stage, the customer moves into a viewing and confirmation stage, labeled here as “product presentation.” The product presentation stage provides the user with all the information and data she may need to make that purchase decision, whether by adding the item to a shopping cart or signing up for the service. In either case, as the merchant, you need to provide access to the data and information about the product that the user may seek to trigger the decision to move to the purchase stage. This could include price comparisons, detailed specifications, or other customers’ reviews.

The purchase stage is the one that most merchants focus on, since at this stage the customer has decided to make a purchase and proceeds to check out. However, as with the other stages, there are additional features and experiences beyond just the process of entering payment information that can make this stage less complex for the customer. This stage can even be turned into a potentially rewarding process for both the customer and the merchant, through couponing, seamless payments, and opportunities to give to causes. This may increase the likelihood of the customer returning to make more purchases and referring new customers.

After the purchase transaction, the lifecycle continues through order fulfillment and, following this, the customer’s use of the good or service purchased. These two stages are often something of an afterthought, due to other efforts being deemed higher priority. However, they can in fact have the greatest impact on whether a customer recommends the product or service and, more importantly, whether he returns to the merchant for future purchases.

The order fulfillment stage represents the period of time after the purchase and until the customer has received the product or service. Timely delivery and communication are essential to passing through this stage smoothly. The last stage—consumption and sharing—is when customers make their final decisions about their commerce experience, formulate opinions of the product or service purchased, and in turn share these opinions—good or bad—throughout their social networks. At the conclusion of this stage, the cycle should not end; instead, if handled well, this stage can feed into the beginning of new cycles with the same customers or contacts in their social networks. The goal is to keep the cycle going and increase the merchant’s customer base and sales.

Audience

We can compare the simplified lifecycle of commerce with a standard software development process, as seen in the inner circle of Figure 1. And just as the simplified lifecycle of commerce works to have multiple revolutions, the software development lifecycle continually improves the resulting products through multiple revolutions. The examples in this book will cover each of these stages, with best practices and notes included with the working technical components.

The book is designed for you, the developer who may have developed ecommerce storefronts, but is looking to or has been tasked with differentiating the business with additional functionality. This differentiation could take the form of incorporating additional features or simplifying procedural steps. A solid programming foundation will be required to implement these examples and apply them to your individual needs. The book assumes you have a hands-on understanding of PHP, HTML, CSS, and JavaScript. While you may not have specific experience with the APIs employed here, the examples are detailed enough to get you started. And even if you are an experienced developer who uses these APIs daily, these examples will hopefully give you some insight into other possible ways to employ the API set, or one of the many other APIs from the other sites referenced in the book.

There are three things working against creating this type of cookbook of commerce examples. First, the examples shown here attempt to meet specific needs, and it has been arduous to pick those examples that will be the most impactful to the most people. Secondly, while we will cover a wide array of eBay-owned APIs, it would be impossible to cover the API set in its entirety in this short text. Lastly, the APIs can of course be integrated into a wide set of technologies, and I only have room to show one implementation. So in the end, this is just a sampling of APIs that can be employed and applied to the stages of the simplified commerce lifecycle. The goal of the solutions picked for inclusion here is to provide an introduction to the wide set of APIs that are part of the eBay properties available, while touching on some of the more directly applicable examples of enhancing the commerce lifecycle in all its stages.

For your specific solution you may be coding in some other language than that used in these examples, but the logic flow for each example should be fairly similar. The examples included here are meant to drive creativity and provide examples on which to base your own solutions. The code examples are exactly that, examples, and are not necessarily meant to be drop-in production-quality code. You will want to add in your own level of deeper error handling and integration. An effort has been made to point out in the examples where these handlers and modularization would be important. Ultimately, the goal is to provide individual examples that can be independently applied to a wide variety of solutions for you, the commerce developer.

How This Book Is Organized

The book consists of five chapters following the simplified commerce lifecycle:

  • Chapter 1 provides examples covering the mapping of product availability to location using Milo, listing your products on eBay, and incorporating product reviews from eBay into your site.

  • Chapter 2 provides examples including customizing the Magento storefront, personalizing a store experience with PayPal Access, and presenting similar items from eBay.

  • Chapter 3 provides examples including autogenerating coupons with Magento, payment preapproval, and donating on checkout with PayPal Adaptive Payments.

  • Chapter 4 provides examples covering shipping form creation with PayPal Instant Payment Notifications, shipping method extensions with Magento, and multiple supplier payment with PayPal chained payments.

  • Chapter 5 includes examples on facilitating social recommendations with QR codes, generating taste graphs and recommendations via Hunch, and social sharing using mashups through ql.io.

One can write about the steps needed to enhance a specific commerce flow, but there is nothing like doing it firsthand. This book is laid out with working examples (three per chapter) that can be taken in part or as a whole and applied to a business built on commerce flows. Each example is built to take advantage of one or more sets of readily available APIs from one of the multiple eBay-owned businesses.

There is a description of an opportunity that the example is driving to take advantage of and a high-level view of a possible solution at the beginning of each example. Then the example dives into a step-by-step implementation of the solution. While the examples in this book provide each step needed to complete a working project with the specific APIs, the goal is also to empower you with knowledge of how the APIs work, and most importantly, how to work with the APIs outside of the confines of these examples. Thus, you will not only have the benefit of seeing how to use the specific examples in your website or application, but you will also gain knowledge about these APIs for your toolbox going forward.

In the step-by-step directions, I have tried to also focus on providing tips and tricks for integrating the code into your own site and troubleshooting when things do not go so smoothly. Knowing how to troubleshoot the issues can be critical—whether because of configuration differences or just the intricacies of trying to modify the examples to fit your needs, it’s inevitable that something will not work.

To try and reach the broadest audience, the examples use some of the more standard web technologies, including PHP, JavaScript, HTML, and CSS. Where possible, the examples use the latest implementations of the technologies, such as various HTML5 and CSS3 features, while at the same time trying to stay clear of technologies that may not currently be universally supported across browsers.

If the opportunity presents itself, other technologies or libraries used in the industry today (such as JQuery) are brought in so that you can see various methods of implementation. When applicable in the examples, notes, recommendations, and best practices are also inserted to save you time and expedite integration of the APIs. At the end of each example a section titled “See Also” is appended, with links to various supporting information and material for working with the APIs used in the example. This section is not meant as an exhaustive list of resources, but rather as a reference to the key areas where you can find more information for your specific implementation.

Differentiating Your Offering

The expectations of customers are changing by the minute, and technologies are allowing for great new commerce delivery methods. It is difficult enough to build your business and keep up with these demands, without even considering trying to differentiate your offering.

This is where external APIs come into play and can be extremely helpful. There are numerous methods available to enhance the lifecycle described earlier by creating stronger relationships, increasing the number of prospective sales that are completed, and encouraging customers to return. Building these features into your solution from scratch can be prohibitive from both a cost and a timing perspective, but through the use of external APIs you can leverage the work of others and integrate the knowledge, information, and data held in systems throughout the Web into your own. Doing so gives you the opportunity to increase the numbers of consumers that successfully complete cycles and to differentiate your offering along the way.

Some of the more prominent questions that you may have asked already to fuel your own commerce cycle include:

  • How do I make my products or services visible to targeted consumers?

  • How can I leverage social commerce efficiently?

  • How can viral marketing take off around my offering?

The intention of this book is to get your creative juices flowing and give you ideas that can be applied to answer these types of questions. The book has combined passions of mine, including business commerce strategy and APIs, to solve technical challenges. It is my hope that you find the cookbook beneficial for your projects, whether you’re dealing with ecommerce, mcommerce, scommerce, or even the “x-commerce” that has not been created yet.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, file paths, and file extensions

Constant width

Used for program listings and commands to be typed literally by the user, as well as within paragraphs to refer to program elements such as variable or function names, databases, statements, and keywords

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context

Note

This icon signifies a tip, suggestion, or general note.

Warning

This icon indicates a warning or caution.

This Book’s Example Files

You can download all of the code examples for this book from GitHub at the following location:

https://github.com/cahudson/eBayCommerceCookbook

In the example files you will find the completed versions of the applications built in the book, which will contain all the code required to run them. In a few cases you will need to download additional content files, such as SDKs, from their original sites before running the application; consult the README file in the top-level folder for details.

Using Code Examples

This book is here to help you get your job done. In general, if this book includes code examples, you may use the code in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “eBay Commerce Cookbook by Chuck Hudson (O’Reilly). Copyright 2013 Chuck Hudson, 978-1-449-32015-7.”

If you feel your use of code examples falls outside fair use or the permission given here, feel free to contact us at .

Safari® Books Online

Note

Safari Books Online (www.safaribooksonline.com) is an on-demand digital library that delivers expert content in both book and video form from the world’s leading authors in technology and business.

Technology professionals, software developers, web designers, and business and creative professionals use Safari Books Online as their primary resource for research, problem solving, learning, and certification training.

Safari Books Online offers a range of product mixes and pricing programs for organizations, government agencies, and individuals. Subscribers have access to thousands of books, training videos, and prepublication manuscripts in one fully searchable database from publishers like O’Reilly Media, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, Course Technology, and dozens more. For more information about Safari Books Online, please visit us online.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

O’Reilly Media, Inc.
1005 Gravenstein Highway North
Sebastopol, CA 95472
800-998-9938 (in the United States or Canada)
707-829-0515 (international or local)
707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/ebay-cookbook.

To comment or ask technical questions about this book, send email to .

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Acknowledgments

First, thank you to Mary Treseler, editorial strategist with O’Reilly Media, who from day one has believed in the proposal for this book and supported it through all the stages. Mary, you have been extremely patient as unexpected events throughout the project threw off already tight timelines. With your fortitude for driving projects we now have a text that I can indeed say I am proud of. I thank you for the opportunity.

The effort that goes into creating a book such as this is all-consuming and takes a toll on friendships and family. Thank you to all my friends and family for their understanding while I have disappeared to complete this project. Without your ongoing support I could not have finished it, and I look forward to catching up.

Over the years the people designing, creating, and supporting the APIs discussed in the text have been extremely open with their time and knowledge, helping me solve some challenging problems. Without the team at X.commerce, PayPal, and eBay, who have not only been evangelists for the APIs but also reviewers, editors, and contributors, this book would not have been possible. Special thanks especially to Praveen Alavilli, John Jawed, Jonathan LeBlanc, and Matthew Russell for their endless knowledge sharing, review feedback, and guidance. Their input has greatly strengthened the quality and value of the examples. Thank you also to Carolyn Mellor and Delyn Simons for the many opportunities you have provided to me along the way in the eBay ecosystem. I look forward to our paths crossing on future projects, wherever they may take us.

Lastly, thank you to all the project partners that have provided the opportunity to create solutions to challenging business problems. The lessons learned and knowledge gained over the years in these projects in both a business strategy and a technical sense are the tools by which I have been able to create this work. I look forward to being continually challenged by the multitude of innovative business ideas and to having the opportunity to lead the next set of disruptions.

Get eBay Commerce Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.