You can use Paypal Services to integrate payment gateway to your code. There are some jars required to download and these have API to do payment.
You need to add those jars in the classpath and call that specific method with required input parameters. You can get details from paypal itself.
For
testing purpose, you can use Test credit card numbers and paypal provide one test url which is similar to real paypal payment gateway URL.
As of now, I am forgetting that test URL but you can get information on google by seraching "Pilot url for Paypal"..
Hope this will help you.
-Sunil