Mobile Express Checkout Library Developer Guide and Reference – Android Edition Last updated: January 2011
PayPal Mobile Payments Developer Guide and Reference – Android Edition Document Number 10126.en_US-201101 © 2011 PayPal, Inc. All rights reserved. PayPal is a registered trademark of PayPal, Inc. The PayPal logo is a trademark of PayPal, Inc. Other trademarks and brands are the property of their respective owners. The information in this document belongs to PayPal, Inc. It may not be used, reproduced or disclosed without the written approval of PayPal, Inc. Copyright © PayPal. All rights reserved.
Contents Preface ............................................................................................................... 4 Purpose ........................................................................................................................ 4 Scope ............................................................................................................................ 4 Revision History ....................................................................................................
Preface The PayPal Mobile Express Checkout Library lets you embed your mobile implementation of Express Checkout in mobile applications for Android devices. Purpose The PayPal Mobile Express Checkout Library lets you embed Express Checkout in Android applications. Download the library from x.com/mobile and include it in your application. You need only a few lines of code to integrate the library and your Express Checkout implementation in your mobile application.
1. PayPal Mobile Express Checkout Library This section provides details about the Mobile Express Checkout Library. It provides instructions and examples for using the library to embed your mobile implementation of Express Checkout in your Android application. Mobile Express Checkout Library API Reference The library supports 2 programming flows. They differ in where you place the PayPal button that buyers click to begin checking out with PayPal.
Programming Flow with the PayPal Button on Your Mobile Website Place the PayPal button on your mobile website if your checkout process begins and ends with pages on your mobile website. In this programming flow, you embed your entire web based checkout implementation in a web view. 1. Fetch a device token from the library, just before you open a web view of your mobile Express Checkout implementation. Include a PayPalListener that receives device tokens. 2.
public static void fetchDeviceReferenceTokenWithAppID(Context context, String appID, int server, PayPalListener listener); Parameter Description context The Context from your Activity. appID PayPal Application ID from X.com. For the Sandbox environment, use APP-80W284485P519543T. server Which PayPal servers the library uses Allowable values are: ENV_LIVE ENV_SANDBOX ENV_NONE NOTE: The ENV_LIVE environment does not support simulators.
Parameter Description textType Type of text that will appear on the button. Allowable values are: TEXT_PAY TEXT_DONATE getInstance Method The library provides a singleton instance of the PayPal object. Use the getInstance method to set and access runtime properties of the library. For example, use the isLibraryInitialized function to determine whether your attempt to fetch a device token was successful.
PAYPAL_BUTTON_TYPE PayPal displays the following images for buyers on the mobile device. BUTTON_152x33: BUTTON_194x37: BUTTON_278x43: BUTTON_294x45: Localization Support in the Mobile Express Checkout Library The Mobile Express Checkout Library supports many locales. Set the locale after you initialize the library. The default is the locale of the device. If the library does not support the device locale, the library uses en_US, instead.
Locales Supported by the Mobile Express Checkout Library The lang property of the PayPal object allows these values.
4. Select Add JARs… on the right and select the paypal_mecl.jar. Method Sequence with the PayPal Button in Your Mobile App The following diagram illustrates the sequence of methods that embed only the mobile PayPal payment pages in a web view within your mobile application. IMPORTANT: Never send Express Checkout requests from your mobile application directly to PayPal. The requests require your PayPal API credentials.
devices exposes you and PayPal to unacceptable security risks. Send Express Checkout requests only from secure servers. Method Sequence with the PayPal Button on Your Mobile Webpage The following diagram illustrates the sequence of methods that embed your entire mobile Express Checkout implementation in a web view within your mobile application.
Sample Code The sample code in this section comes from sample application code included with the download of Mobile Express Checkout Library. Get the download of the library from x.com/mobile. Fetching the Device Token Regardless where you place the PayPal button, you must fetch a device token from the library by calling fetchDeviceReferenceTokenWithAppID(). If you place the PayPal button in your mobile application, fetch a device token just before you get the PayPal button.
Completing the Payment Whether you place the PayPal button in your mobile application or on your mobile website, complete the payment by sending GetExpressCheckoutDetails and DoExpressCheckoutPayment requests from your mobile website. IMPORTANT: Never send Express Checkout requests from your mobile application directly to PayPal. The requests require your PayPal API credentials. Placing your credentials on mobile devices exposes you and PayPal to unacceptable security risks.
2. The Checkout Experience with the Mobile Express Checkout Library The screen shots that follow illustrate the checkout experience when you embed your mobile implementation of Express Checkout in your mobile application. The embedded checkout experience is the same whether you place the Checkout with PayPal button in your mobile application or on your mobile website.
PayPal displays the mobile PayPal Review page after buyers log in successfully. The mobile Review page fully supports Express Checkout when you include a device token with your redirect to PayPal. When satisfied with the payment information the Review page, buyers click Continue to complete the payment in your mobile application or on your mobile website. If buyers pay on PayPal in your implementation of Express Checkout, the button label on the review page reads, “Pay Now” instead of “Continue.
3. Submitting Your Application to PayPal Log in or sign up on PayPal’s developer website www.x.com. From there, click the MyApps tab to submit your mobile application. PayPal reviews applications within 24 hours and responds by sending you your PayPal Application ID.