Developer's Guide
10 July 2011 PayPal Mobile Payments Developer Guide and Reference – Android OS Edition
Required Methods in the Mobile Payments Library
initWithAppID Method
The initWithAppID method creates and returns the PayPal object. You must pass in the context
and the unique application ID (appID) that PayPal has provided. You can choose whether to use
the live or sandbox server, or use non-networked (Demo) mode (see below).
static public PayPal initWithAppID(Context context, String appID, int
server)
An example of initializing the Library with this method is:
PayPal ppObj = PayPal.initWithAppID(this.getBaseContext(), "APP-
80W284485P519543T", PayPal.ENV_SANDBOX);
Parameter
Description
context:
(Required) The context.
appID:
(Required) PayPal Application ID from X.com.
This will be different for each server. Thus, the appID will be
different for Stage and Sandbox. Any appID value can be used when
testing on „none‟ since the library does not contact the server when
set to this.
server:
(Required) Sets the PayPal server to Live, Sandbox, or None.
Allowable values are:
ENV_LIVE – Use the PayPal production servers.
(does not support simulators)
ENV_SANDBOX – Use the PayPal testing servers.
ENV_NONE - Do not use any PayPal servers. Operate in
demonstration mode, instead. Demonstration mode lets you view
various payment flows without requiring production or test accounts
on PayPal servers. Network calls within the library are simulated by
using demonstration data held within the library.
NOTE: The initWithAppID method should only be invoked once. After initialization,
reference the PayPal object using the getInstance method instead. Calling the
initWithAppID method more than once will throw an IllegalStateException.
NOTE: If you do not set the optional parameter forEnvironment, the library defaults to use
the PayPal production the servers. When testing your application, PayPal recommends that
you initialize the library to use the PayPal test servers, instead.
NOTE: The Mobile Payments Library binds specific devices to specific application IDs, for
enhanced security. For each of your application IDs, you must use a different sandbox