Chapter 1. PayPal API Overview

This chapter provides a very brief overview of PayPal’s Name-Value Pair (NVP) APIs, the primary way that you’ll interact with PayPal products throughout the remainder of this book. Since using the NVP APIs is as simple as making some HTTP requests and parsing the responses, we’ll get a Python project up and running with Google App Engine (GAE) as part of this initial overview. Future chapters all use Python-based GAE projects, so unless you’re definitely planning to port the code without running it, you should make the most of this opportunity to learn the basics. After reading this chapter, it is highly recommended that you check out and run the sample code for Tweet Relevance as introduced in Appendix A.

PayPal’s NVP API makes it simple to integrate payments into your application. As the merchant, your web application constructs an NVP string and transmit it via HTTPS (HTTP Secure) to the PayPal authorization server, and PayPal sends back an NVP-formatted response that your web application parses for the information relevant to the payment. Figure 1-1 shows this basic request and response workflow, which is typical of just about any web application.

The request identifies:

The PayPal API server executes the operation and returns a response containing:

Some PayPal products such as Express Checkout require calls to multiple API operations, while others such as Direct Pay (part of Website Payments Pro) only require one call. We’ll review Express Checkout in the next chapter, but Figure 1-2 is included to illustrate its typical flow, which should look pretty familiar and intuitive if you’ve ever used PayPal. Either way, interacting with PayPal products is just a series of API calls that allow you to accomplish a wide variety of tasks. A few examples of the possible transactions PayPal products support include:

  • Accepting PayPal as part of a streamlined checkout process

  • Charging a credit card

  • Capturing previously authorized payments

  • Reauthorizing or voiding previous authorizations

  • Paying single or multiple recipients

  • Issuing full or partial refunds

  • Searching transactions histories

  • Retrieving details of specific transactions

  • Processing payments involving more than one party

  • Setting up recurring subscription charges

  • Accepting Donations

With a broad understanding of how payment transactions are implemented, let’s briefly segue into an overview of GAE and how to implement HTTP requests, the essential skill required to interact with PayPal APIs.