Client Class Documentation

June 5, 2026 ยท View on GitHub

The following parameters are configurable for the API Client:

ParameterTypeDescription
environmentEnvironmentThe API environment.
Default: Environment.SANDBOX
httpClientConfigConsumer<HttpClientConfiguration.Builder>Set up Http Client Configuration instance.
loggingConfigConsumer<ApiLoggingConfiguration.Builder>Set up Logging Configuration instance.
clientCredentialsAuthClientCredentialsAuthThe 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();

    }
}

PayPal Server SDKClient Class

The gateway for the SDK. This class acts as a factory for the Controllers and also holds the configuration of the SDK.

Controllers

NameDescriptionReturn Type
getOrdersController()Provides access to Orders controller.OrdersController
getPaymentsController()Provides access to Payments controller.PaymentsController
getVaultController()Provides access to Vault controller.VaultController
getTransactionSearchController()Provides access to TransactionSearch controller.TransactionSearchController
getSubscriptionsController()Provides access to Subscriptions controller.SubscriptionsController
getOAuthAuthorizationController()Provides access to OAuthAuthorization controller.OAuthAuthorizationController

Methods

NameDescriptionReturn Type
shutdown()Shutdown the underlying HttpClient instance.void
getEnvironment()Current API environment.Environment
getHttpClient()The HTTP Client instance to use for making HTTP requests.HttpClient
getHttpClientConfig()Http Client Configuration instance.ReadonlyHttpClientConfiguration
getLoggingConfig()Logging Configuration instance.ReadonlyLoggingConfiguration
getClientCredentialsAuth()The credentials to use with ClientCredentialsAuth.ClientCredentialsAuth
getBaseUri(Server server)Get base URI by current environmentString
getBaseUri()Get base URI by current environmentString