Skip to content

Latest commit

 

History

History
73 lines (59 loc) · 3.57 KB

File metadata and controls

73 lines (59 loc) · 3.57 KB

Client Class Documentation

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();

    }
}

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

Name Description Return 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

Name Description Return 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 environment String
getBaseUri() Get base URI by current environment String