2016-01-08

PayPal is a popular international platform over internet for making payments and money transfers. PayPal provides APIs and payment gateways to be integrated with any website (ecommerce and non-ecommerce) so that website users can transact with money.

In this tutorial we will see about integrating PayPal in our Java based website.

Create PayPal Account (if not available)

To start with, first of all we must have one account created on PayPal.com for sending or receiving money.

Create Two Sandbox Accounts – Seller and Buyer

After creating account on PayPal we will have to create two sandbox accounts for testing, one for seller and second for buyer. Sandbox account is a kind of dummy account provided by PayPal for testing purpose. For this we need to login in Paypal’s developer site and create an account here. http://developer.paypal.com/webapps/developer/applications/accounts/

We can verify the creation of our sandbox accounts here. https://www.sandbox.paypal.com/

Understanding of PayPal NVP API

So we have done the initial setup of account creation on PayPal site. Before moving further I am assuming that you already know about the concept and have seen the demo related to PayPal NVP API. Just in case if you are not aware or not seen the demo, then you can visit here, https://demo.paypal.com or you can directly download the demo related to Java from here https://demo.paypal.com/codesamples_zip/java/PayPalCredit_java.zip

NVP – The Name-Value Pair (NVP) API provides parameter-based association between request and response fields of a message and their values. The request message is sent from client which is nothing but your website and response message will come from Paypal using client-server mode.

You can read more about NVM here https://developer.paypal.com/docs/classic/api/NVPAPIOverview/

Collect API Credentials for Seller Account

Before integrating with our Java web application we need to have API credentials for Seller Account.

API Username

API Password

Signature

We can get above details by following below steps,

Log in to seller account

On Home page click on –> Profile

click on –> Request API credentials

click on –> View API Signature

Integrate Seller Account with Java Web Application

Open config.properties file and set API credentials of seller.

SANDBOX_FLAG : Keep it true when working with sandbox / demo accounts, later when going live it needs to be false.

Copy all files and folders under the downloaded “PaypalCredit” package to the same location where you have your shopping cart page.

Run it’s index file or you can make your own index file with your desire name if you want to integrate it with your web application. If you want to make your own index file than copy the below.

Pass additional input parameters based on your shopping cart. For complete list of all the parameters use this link.

Now run your own index file or whatever name you have given to index file, click on “Paypal Credit” button and complete the flow by entering buyer credential (email id, password) whenever asked.

So this is how we can integrate PayPal with our Java based website application. If you have any questions post it below.

Author : VikasHJ

Show more