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.
- 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.
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.
Find out more here: https://developer.paypal.com/docs/api/orders/v2/
The generated code uses the Newtonsoft Json.NET NuGet Package. If the automatic NuGet package restore is enabled, these dependencies will be installed automatically. Therefore, you will need internet access for build.
- Open the solution (PaypalServerSDK.sln) file.
Invoke the build process using Ctrl + Shift + B shortcut key or using the Build menu as shown below.
The build process generates a portable class library, which can be used like a normal class library. More information on how to use can be found at the MSDN Portable Class Libraries documentation.
The supported version is .NET Standard 2.0. For checking compatibility of your .NET implementation with the generated library, click here.
The following section explains how to use the PaypalServerSdk.Standard library in a new project.
For starting a new project, right click on the current solution from the solution explorer and choose Add -> New Project.
Next, choose Console Application, provide TestConsoleProject as the project name and click OK.
The new console project is the entry point for the eventual execution. This requires us to set the TestConsoleProject as the start-up project. To do this, right-click on the TestConsoleProject and choose Set as StartUp Project form the context menu.
In order to use the PaypalServerSdk.Standard library in the new project, first we must add a project reference to the TestConsoleProject. First, right click on the References node in the solution explorer and click Add Reference...
Next, a window will be displayed where we must set the checkbox on PaypalServerSdk.Standard and click OK. By doing this, we have added a reference of the PaypalServerSdk.Standard project into the new TestConsoleProject.
Once the TestConsoleProject is created, a file named Program.cs will be visible in the solution explorer with an empty Main method. This is the entry point for the execution of the entire solution. Here, you can add code to initialize the client library and acquire the instance of a Controller class. Sample code to initialize the client library and using Controller methods is given in the subsequent sections.
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 |
Timeout |
TimeSpan |
Http client timeout. Default: TimeSpan.FromSeconds(100) |
LogBuilder |
LogBuilder |
Represents the logging configuration builder for API calls |
ClientCredentialsAuth |
ClientCredentialsAuth |
The Credentials Setter for OAuth 2 Client Credentials Grant |
The API client can be initialized as follows:
PaypalServerSDKClient client = new PaypalServerSDKClient.Builder()
.ClientCredentialsAuth(
new ClientCredentialsAuthModel.Builder(
"OAuthClientId",
"OAuthClientSecret"
)
.Build())
.Environment(PaypalServerSDK.Standard.Environment.Sandbox)
.LoggingConfig(config => config
.LogLevel(LogLevel.Information)
.RequestConfig(reqConfig => reqConfig.Body(true))
.ResponseConfig(respConfig => respConfig.Headers(true))
)
.Build();API calls return an ApiResponse object that includes the following fields:
| Field | Description |
|---|---|
StatusCode |
Status code of the HTTP response |
Headers |
Headers of the HTTP response as a Hash |
Data |
The deserialized body of the HTTP response as a String |
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.