Integrate Paypal SDK on Android to make payment

Paypal provides the official Paypal Android SDK to let the android developer easy to make payment by using PayPal in the android application. Paypal is the most popular payment method that used in the world which widely accepts in every country. As a developer, you can integrate the PayPal SDK in your android application so you can be selling your products or services to get some income. In this tutorial, I will teach you all the steps to integrate PayPal SDK on Android to make payment in the application. It is much safer, convenient and fast.

Register a Paypal developer account

In your browser navigate to the PayPal developer website link and log in your PayPal account or register a new account.

Create Sandbox Test Account

After that, go to //developer.paypal.com/developer/accounts to create a business account (merchant acount) and a personal account (buyer account).

paypal1-a

Create REST API app

Go to //developer.paypal.com/developer/applications/ and create a new rest API app by clicking the create app button. After that, you will need to fill in some information.

paypal2-a

Copy Client ID

After creating REST API app to test, click into the app name “Test”(this is my app name) to check out your client id and copy it, you will need to use the client id in the android project later.

paypal3-a

Creating a New Project

1. Open Android Studio IDE in your computer.
2. Create a new project and Edit the Application name to “PayPalExample”.
(Optional) You can edit the company domain or select the suitable location for current project tutorial. Then click next button to proceed.
3. Select Minimum SDK (API 15:Android 4.0.3 (IceCreamSandwich). I choose the API 15 because many android devices currently are support more than API 15. Click Next button.
4. Choose “Empty Activity” and Click Next button
5. Lastly, press finish button.

Add dependency

Open build.gradle (Module: app) and add the following source code in your dependencies section to add the PayPal SDK in your app.

Edit activity_main.xml layout

After that, go to your activity_main.xml to edit the layout. I will add a button to demo the PayPal payment method. You can follow the source code in the bottom section.

Edit MainActivity.java class

In this class, paste your client id in the PAYPAL_CLIENT_ID variable, in this class will perform all the paypal transaction in the application.

Run your project

Now, you can try and run it on your android device to make the payment with PayPal SDK.

Login Sandbox test account

After making the payment, navigate to //www.sandbox.paypal.com/my/webapps/mpp/home to log in your sandbox business account and personal account to check out the transaction.

paypal4-a

(Integrate Paypal SDK on Android)

Source Code

 

(Visited 908 times, 1 visits today)
Advertisements

Yong Loon Ng

Ng Yong Loon, better known as Kristofer is a software engineer and computer scientist who doubles up as an entrepreneur.

You may also like...

2 Responses

  1. Hy, thank you for your tutorial.
    Please, what I need to change, when I put online the app and receive to receive the money?

  2. Hi, i have an error when the login activity paypal show, the error is “Incorrect login” but my credentials are fine… do you know what could the problem?

Leave a Reply

Your email address will not be published. Required fields are marked *