Integrate PayPal in LiftWeb application using Scala

Table of contents
Reading Time: 3 minutes

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
  • 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 .
    Screenshot from 2013-03-04 20:50:20

    Compose the BuyNowSnippet with your snippet:

    Above lines are required to implement the button .

  • Finally add PayPal response pages to the SiteMap .

Written by 

Ayush is the Sr. Lead Consultant @ Knoldus Software LLP. In his 10 years of experience he has become a developer with proven experience in architecting and developing web applications. Ayush has a Masters in Computer Application from U.P. Technical University, Ayush is a strong-willed and self-motivated professional who takes deep care in adhering to quality norms within projects. He is capable of managing challenging projects with remarkable deadline sensitivity without compromising code quality.

2 thoughts on “Integrate PayPal in LiftWeb application using Scala2 min read

  1. Change PaypalHandler.dispatch.foreach([LiftRules.dispatch.append(_))

    Good article

Comments are closed.