Getting Started with PayPal Server SDK

Introduction

⚠️ Beta Release Notice

This version is considered a beta release. While we have done our best to ensure stability and functionality, there may still be bugs, incomplete features, or breaking changes in future updates.

Important Notes

  • Available Features: This SDK currently contains only 3 of PayPal's API endpoints. Additional endpoints and functionality will be added in the future.
  • API Changes: Expect potential changes in APIs and features as we finalize the product.

Information

The PayPal Server SDK provides integration access to the PayPal REST APIs. The API endpoints are divided into distinct controllers:

Find out more here: https://developer.paypal.com/docs/api/orders/v2/

Install the Package

Install the SDK by adding the following dependency in your project's pom.xml file:

<dependency>
  <groupId>com.paypal.sdk</groupId>
  <artifactId>paypal-server-sdk</artifactId>
  <version>0.6.0</version>
</dependency>

You can also view the package at: https://central.sonatype.com/artifact/com.paypal.sdk/paypal-server-sdk/0.6.0

Initialize the API Client

Note: Documentation for the client can be found here.

The following parameters are configurable for the API Client:

Parameter Type Description
environment Environment The API environment.
Default: Environment.SANDBOX
httpClientConfig Consumer<HttpClientConfiguration.Builder> Set up Http Client Configuration instance.
loggingConfig Consumer<ApiLoggingConfiguration.Builder> Set up Logging Configuration instance.
clientCredentialsAuth ClientCredentialsAuth The Credentials Setter for OAuth 2 Client Credentials Grant

The API client can be initialized as follows:

PaypalServerSdkClient client = new PaypalServerSdkClient.Builder()
    .loggingConfig(builder -> builder
            .level(Level.DEBUG)
            .requestConfig(logConfigBuilder -> logConfigBuilder.body(true))
            .responseConfig(logConfigBuilder -> logConfigBuilder.headers(true)))
    .httpClientConfig(configBuilder -> configBuilder
            .timeout(0))
    .clientCredentialsAuth(new ClientCredentialsAuthModel.Builder(
            "OAuthClientId",
            "OAuthClientSecret"
        )
        .build())
    .environment(Environment.SANDBOX)
    .build();

API calls return an ApiResponse object that includes the following fields:

Field Description
getStatusCode Status code of the HTTP response
getHeaders Headers of the HTTP response as a Hash
getResult The deserialized body of the HTTP response as a String

Environments

The SDK can be configured to use a different environment for making API calls. Available environments are:

Fields

Name Description
Production PayPal Live Environment
Sandbox Default PayPal Sandbox Environment

Authorization

This API uses the following authentication schemes.

List of APIs

Classes Documentation