Integration of PayPal with Android Application

The easiest way to process payment through Android application is by integrating PayPal. There are two ways to integrate PayPal into an Android application :

Mobile Payment Library :

(For Android 1.5 and above-supported devices)
Using Mobile Payment Library we can process payment without leaving the android application. This Library controls the checkout experience –logging in, reviewing and completing the payment. In a few steps we can integrate mobile payment library in our application :

Mobile Express Checkout Library:

There are two ways to integrate mobile checkout library with your application

  1. PayPal Button in your Mobile Application
  2. PayPal Button on your mobile Website

(Note: Download mobile payment library for Android from this link https://www.x.com/developers/paypal/documentation-tools/paypal-sdk-index and add library file to your project classpath.)

PayPal Button in your Mobile Application:

Place PayPal Button in your mobile application and load mobile express checkout library pages in a WebView.

PayPal Button in your Mobile Website:

Place PayPal Button on your mobile website page if your checkout process begins and ends with mobile express checkout.

(Reference:https://www.x.com/developers/paypal)

Methods of Mobile Express Checkout Library:
  1. Get Device Token:
    public static void fetchDeviceReferenceTokenWithAppID(Context context, String appID, int server, PayPalListener listener)
    Parameter:
    Context : activity or application context
    appId: Application Id registered on www.x.com
    server :ENV_SANDBOX
    ENV_LIVE (Not support on emulator)
    ENV_NONE
  2. PayPal Button:public CheckoutButton getCheckoutButton(Context context, int style, int textType)

    Parameter:
    Context: activity or application context
    Style: style and appearance of PayPal Button
    Allowed value:

    1. PayPal.Button_152x33
    2. PayPal.Button_194x37
    3. PayPal.Button_278x43
    4. PayPal.Button_294x45

    type : Type of button
    Allowed value:

    1. CheckoutButton.TEXT_PAY
    2. CheckoutButton.TEXT_DONATE
  3. PayPal Listener: Two Methods of PayPal Listener
    @Override
    public void couldNotFetchDeviceReferenceToken() {
    //Initialization failed and we didn't get a token
    }
    @Override
    public void receivedDeviceReferenceToken(String token) {
    //Initialization was successful
    }

More information about PayPal integration with android refer https://www.x.com/developers/paypal.

Download source code from here.

Exit mobile version