Friday, August 3, 2012

Paypal Integration in java


Paypal is the one of the famous payment gateway within the world.It is commonly used by multiple website in web world.I am just sharing my idea about the Paypal with java integration.
Paypal is providing the developer guideline and url where we can test our local application.we will use the express checkout method for payment in this example.
1. Open the paypal developer link https://developer.paypal.com/
2. We need to create two different email address , One for Merchant and other for buyer respectively.
3. Click on “Sign Up Now” button.
4. Enter the your information to access the sandbox environment.
5. Click on “Agree and Submit” button.
6. Now login with given username/password.
7. Click on “Test Account” link
8. Create a new test account and provide the details in textfields also.
9. Select the “Account Type” as you want either “Merchant”  or “buyer”
10.It will generate the default email id for us.
11.Set Credit card information as “NONE” .
12.Set the balance amount for your account.
As per my acknowledgement ,you have created both merchant and buyer account within your account.
13.Now click on the “API Credentials” link
14.Copy the your API username, API password and Singature.
Now Our paypal configuration has been done. Now we will create the web project in eciplse.
1. Create the following JSP files in WEBROOT path
paypalpay.jsp
paypalResponse.jsp
paypalResponseCancel.jsp
2. Put the following code in paypalpay.jsp
1. Set your generated API username,API password and API Singature at their place.
2. You can also set the following value like item name,amount ,custom charge and rm
3. You can also set return and cancel return URL for your application.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<html>
<head>
<title>Pay through PayPal: www.TestAccount.com</title>
</head>
<body onload="document.forms['paypalForm'].submit();">
<form name="paypalForm" action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
 <input type="hidden" name="cmd" value="_xclick" />
 <input type="hidden" name="business" value="API username" />
 <input type="hidden" name="password" value="API password" />
 <input type="hidden" name="custom" value="1123" />
 <input type="hidden" name="item_name" value="Computer-Laptop" />
 <input type="hidden" name="amount" value="30"/>
 <input type="hidden" name="rm" value="1" />
 <input type="hidden" name="return" value="http://localhost:8080/PaypalGS/paypalResponse.jsp" />
 <input type="hidden" name="cancel_return" value="http://localhost:8080/PaypalGS/paypalResponseCancel.jsp" />
 <input type="hidden" name="cert_id" value="API Singature" />
</form>
</body>
</html>
3.     Create two basic jsp file
1 paypalResponse.jsp (for response handling)
2 paypalResponseCancel.jsp    (for Cancel handling process)

No comments:

Post a Comment