Payouts SDK

DocsCurrent


Use the Payouts REST SDK to get started quickly with the Payouts REST API and complete common actions.

The Payouts REST SDK is available in Java, PHP, Node, Python, Ruby, and .NET.

Benefits

Using an SDK over a direct integration allows the SDK to handle authentication for you. The SDK obtains your OAuth 2.0 access token and automatically reflects any Payouts API updates.

Install

To begin working with the payouts REST API, install the SDK in your preferred language.

  1. Node
  2. PHP
  3. Python
  4. Ruby
  5. Java
  6. .NET
1//Create a Node.js project in your directory, then run the following command to install the PayPal JavaScript SDK.
2npm install @paypal/payouts-sdk

Set up environment

After you install the SDK, make it available to your app and configure your environment. Configuration details include either sandbox for testing or live for production, and your client ID and secret for your app.

Note: Learn how to get your REST API credentials for sandbox and live environments in the Developer Dashboard.

In the directory where you installed the SDK, create a file in your preferred language. Include this code to make the SDK available and configure your environment with your application credentials.

  1. Node
  2. PHP
  3. Python
  4. Ruby
  5. Java
  6. .NET
1'use strict';
2/**
3 *
4 * PayPal Node JS SDK dependency
5 */
6const payoutsNodeJssdk = require('@paypal/payouts-sdk');
7/**
8 *
9 * Returns PayPal HTTP client instance with environment that has access
10 * credentials context. Use this instance to invoke PayPal APIs, provided the
11 * credentials have access.
12 */
13function client() {
14 return new payoutsNodeJssdk.core.PayPalHttpClient(environment());
15}
16/**
17 *
18 * Set up and return PayPal JavaScript SDK environment with PayPal access credentials.
19 * This sample uses SandboxEnvironment. In production, use LiveEnvironment.
20 *
21 */
22function environment() {
23 let clientId = process.env.PAYPAL_CLIENT_ID || 'PAYPAL-SANDBOX-CLIENT-ID';
24 let clientSecret = process.env.PAYPAL_CLIENT_SECRET || 'PAYPAL-SANDBOX-CLIENT-SECRET';
25 if (process.env.NODE_ENV === 'production') {
26 return new payoutsNodeJssdk.core.LiveEnvironment('PAYPAL-CLIENT-ID', 'PAYPAL-CLIENT-SECRET');
27 }
28 return new payoutsNodeJssdk.core.SandboxEnvironment('PAYPAL-SANDBOX-CLIENT-ID', 'PAYPAL-SANDBOX-CLIENT-SECRET');
29}
30module.exports = { client: client};

See also