Skip to content
This repository has been archived by the owner on Jul 20, 2020. It is now read-only.

Quick Start

abhijith-prabhakar edited this page Apr 14, 2013 · 4 revisions

Log In with PayPal (formerly PayPal Access) is a commerce identity solution that enables your customers to sign in to your web site quickly and securely using their PayPal login credentials

More information on 'Login With PayPal' here.

1. Obtain an App ID

Recently updated documentation on how to obtain appid can be found here. Please look under "Creating a Personal test account" section.

2. Add dependencies to the POM

<dependency>
    <groupId>org.springframework.social</groupId>
    <artifactId>spring-social-core</artifactId>
    <version>${org.springframework.social-version}</version>
</dependency>

<dependency>
    <groupId>org.springframework.social</groupId>
    <artifactId>spring-social-web</artifactId>
    <version>${org.springframework.social-version}</version>
</dependency>

<dependency>
    <groupId>org.springframework.social.openidconnect</groupId>
    <artifactId>spring-social-paypal</artifactId>
    <version>${org.springframework.social.paypal-version}</version>
</dependency>

Note that the examples above are using ${...} Maven properties. Refer to the Quickstart Sample POM for a complete sample.

3. Configure Spring Social

Spring Social configuration is done through a class SocialConfig in your application, which defines what Spring Social extension will be used (PayPal in our case). In specific, you need to define the following:

  • The application id and secret obtained in the step #1.
  • A connection factory which defines how Spring Social should connect to the API: PayPalConnectionFactory. You can use PayPalConnectionFactoryBuilder to create the same. Builder also gives additional options.
  • PayPalConnectionFactoryBuilder allows you to override default endpoints. This is done to aid testing. If you want to swap endpoints to stage server or simulator then you can use this feature. You might have to disable strict verifier when you do this.
  • Connections repository for all users and for the current user, so Spring Social can persist the connection data.
  • Connection data can be persisted in a database table or in InMemory Map. OpenId Connect protocol has an extra attribute id_token which is not used in OAuth2 protocol. This token is used on checkid and disconnect endpoints. Hence a new [sql script] (https://github.com/paypal/spring-social-paypal-openidconnect/blob/master/src/main/resources/org/springframework/social/openidconnect/jdbc/OpenIdConnectJdbcConnectionRepository.sql) is provided as part of spring-social-paypal extension jar. If you intend to use JDBC connection repository, then you have to make sure this script is run before.
  • spring-social-paypal extension jar also provides a InMemory connection repository implementation which is not provided by spring-social-core. You can switch to use JDBC or in-memory when you are configuring Connection repository.
  • A bean representing the API calls: Interface PayPal

Use the Quickstart Sample SocialConfig as a template for your own application. Also note that the sample SocialConfig reads the application id and secret id from a property file application.properties

4. Define Login Controllers and Views

Login Pop-up

PayPal Access supports both pop-up-based login and single-window login. To enable the pop-up, we create a window using Javascript when the user clicks on the submit form button, and then the form itself refreshes the pop-up via the target HTML attribute. Then when home.jsp is loading it closes itself and refreshes the parent window

Refer to Quickstart Sample Sign In View

5. Inject the API

Now the PayPal Access API (which is represented by the interface PayPal) is ready to be used, and it can be easily injected into other controllers. See [Quickstart Sample Home Controller] (https://github.com/paypal/spring-social-security-paypal-openidconnect-quickstart/blob/master/src/main/java/org/springframework/social/quickstart/HomeController.java)


Additional Resources: