- Available Features: This SDK currently contains only 5 of PayPal's API endpoints. Additional endpoints and functionality will be added in the future.
The PayPal Server SDK provides integration access to the PayPal REST APIs. The API endpoints are divided into distinct controllers:
- Orders Controller: Orders API v2
- Payments Controller: Payments API v2
- Vault Controller: Payment Method Tokens API v3 Available in the US only.
- Transaction Search Controller: Transaction Search API v1
- Subscriptions Controller: Subscriptions API v1
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>2.0.0</version>
</dependency>You can also view the package at: https://central.sonatype.com/artifact/com.paypal.sdk/paypal-server-sdk/2.0.0
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:
import com.paypal.sdk.Environment;
import com.paypal.sdk.PaypalServerSdkClient;
import com.paypal.sdk.authentication.ClientCredentialsAuthModel;
import com.paypal.sdk.exceptions.ApiException;
import com.paypal.sdk.http.response.ApiResponse;
import com.paypal.sdk.models.OAuthToken;
import java.io.IOException;
import org.slf4j.event.Level;
public class Program {
public static void main(String[] args) {
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();
}
}The SDK can be configured to use a different environment for making API calls. Available environments are:
| Name | Description |
|---|---|
| Production | PayPal Live Environment |
| Sandbox | Default PayPal Sandbox Environment |
This API uses the following authentication schemes.
- ApiLoggingConfiguration
- ApiLoggingConfiguration.Builder
- ApiRequestLoggingConfiguration.Builder
- ApiResponseLoggingConfiguration.Builder
- Configuration Interface
- HttpClientConfiguration
- HttpClientConfiguration.Builder
- HttpProxyConfiguration
- HttpProxyConfiguration.Builder