The PayPal Here SDK for Android gives access to a group of PayPal transaction services. It provides an extensive set of point-of-sale functions for merchants. If you're a merchant, you can use it to develop point-of-sale apps for your own use. If you're a third-party solution provider, you can use it to develop point-of-sale software and services which you can offer to your customers.
What's in the PayPal Here SDK for Android
You must have a GitHub account to obtain the SDK files. A free account is sufficient. Once you have joined, you will have access to the SDK distribution's repository. Clone the repository before you begin development.
The GitHub repository for the PayPal Here SDK for Android contains:
- Object code and other resources for the SDK (in
- Reference (Javadoc) documentation for the SDK. (in
- The PayPal Here SDK for Android Developer Guide (this online document)
- Source code for HereSDKSampleApp, which supports card present transactions with EMV cards, using swipers and using both types of readers (in
- Source code for a sample mid-tier server that operates with the sample apps. (in
How the PayPal Here SDK Works
The PayPal Here SDK for Android is a collection of classes, protocols, and other resources for developing point-of-sale apps that run on Android. It communicates with the underlying PayPal APIs at the following URIs:
https://sandbox.paypal.com/webapps/hereapi/merchant/v1 // Sandbox environment https://www.paypal.com/webapps/hereapi/merchant/v1 // Live environment
The PayPal Here SDK API is a RESTful interface with the following characteristics:
- The data-interchange format is JSON.
- Each request must contain an authentication token; see Authenticating SDK Operations.
An app must perform these setup operations to prepare to process transactions with the PayPal Here SDK:
- Initialize the SDK (each time the app starts).
- Authenticate the merchant and pass the merchant's credentials to the SDK (the first time the merchant uses the app).
- Set the active merchant, for whom the PayPal Here SDK will execute transactions.
- Start monitoring the card reader for events (for card present transactions).
Once the setup operations are complete, an app must perform these steps to process a basic card present transaction:
- Start an invoice.
- Add items to the invoice.
- Take a payment using a credit card reader.
- Capture the customer's signature (if required for this merchant and transaction amount).
- Send a receipt.
These steps are illustrated in the sample apps, and are described in more detail in Working with the SDK.
Alternative workflows and additional capabilities
The SDK supports several alternatives for the steps in the basic workflow:
- A fixed-amount transaction instead of starting an invoice and adding items to it
- A card not present transaction instead of taking and finalizing payment with a card reader
- Authorization and capture (auth/cap for short), which enables you to authorize a transaction at one point in time and capture payment at a later point. Auth/cap is useful for businesses like restaurants, which must authorize a card payment before the customer determines the final amount by adding a gratuity.
The SDK also supports several additional capabilities:
- Issuing a refund
- Adding a referrer code to a transaction
- Adding a cashier ID to a transaction
All of the alternatives and additions to the basic workflow are described in the Working with the SDK section of this document.
Important classes and interfaces
Understanding the functions and roles of the PayPal Here SDK's most important classes will help you understand the detailed descriptions of how to use the SDK that come later in this guide.
- PayPalHereSDK: The primary class for interacting with PayPal, and through the
CardReaderManagerclass, with hardware devices.
- InvoiceItem: Interfaces that represent an invoice and an item in an invoice. Apps generally refer to these interfaces rather than the classes that implement them. The
DomainFactoryclass has methods that construct objects of the appropriate class for an invoice and invoice item, in any given case.
- DomainFactory: A
factoryclass that creates objects representing invoices, invoice items, and other transaction elements.
- TransactionManager: An interface that defines a stateful transaction manager, takes payments and processes refunds on the current invoice (if any).
- CardReaderManager: An interface that defines a card reader manager. Handles interaction with mag stripe and EMV credit card readers, including audio readers, dock port readers, and Bluetooth readers.
- CardReaderListener: Translates between row card reader events and a delegate interface, and supports multiple listeners.
- DefaultResponseHandler: A generalized response handler for PayPal Here SDK methods that need one. When you call such a method, you can provide a response handler to it by constructing an instance of
paramis an object to be passed to the handler
erris an object (customarily an instance of
PPError) to be passed to its
onErrormethod. You can customize the handler behavior by overriding