If you are developing an E-Business web application , where you have to provide online payment solution to your customer then PayPal is one of the most secure , faster and easier way to make payment online .
In this blog, we will have a basic idea that how easily you can integrate PayPal functionality in your Liftweb project using Scala .
We are assuming that you are aware with the basics of LiftWeb and Scala .
Lift provides integration support for both PDT(Payment Data Transfer) and IPN(Instant Payment Notification) . You do not need to add any extra functionality to handle response from PayPal .
Payment Data Transfer :
PDT(Payment Data Transfer) provides you some transaction details to be displayed to buyer , when page is redirected after completing transaction . To use PDT , you must enable AUTO RETURN .
IPN(Instant Payment Notification):
Once transaction is complete , IPN(Instant Payment Notification) sends a notification to your server with all specific details about completed transaction .
PayPal Environment setup :
Before implementing PayPal in your application , you must setup PayPal environment .
- Go To https://developer.paypal.com
- Set up both a “preconfigured seller” and “preconfigured buyer” account in the sandbox.
- Log into the sandbox as the seller account you just created, and enable Auto Return in the selling preferences.
- Enable PayPal Data Transfer (it’s on the same screen as the Auto Return configuration).
- Edit the IPN callback URL and enable IPN.
LiftWeb Environment setup :
- Add PayPal repository in your build.sbt
- Let’s create PayPal Handler class which implements two traits PaypalIPN and PaypalPDT.
- Now add following lines in your Boot.Scala to initialize the PaypalRules object that contains configuration .
- Now add Buy Now button to instantiate the transaction process .
Compose the BuyNowSnippet with your snippet:
Above lines are required to implement the button .
- Finally add PayPal response pages to the SiteMap .