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, Python, 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. PHP
  2. Python
  3. Java
  4. .NET
1//Create a PHP project in your directory, then run the following command to install the PayPal Payouts PHP SDK.
2composer require paypal/paypal-payouts-sdk ~1.0.0

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. PHP
  2. Python
  3. Java
  4. .NET
1<?php
2namespace Sample;
3use PaypalPayoutsSDKCorePayPalHttpClient;
4use PaypalPayoutsSDKCoreSandboxEnvironment;
5ini_set('error_reporting', E_ALL); // or error_reporting(E_ALL);
6ini_set('display_errors', '1');
7ini_set('display_startup_errors', '1');
8class PayPalClient
9{
10 /**
11 * Returns PayPal HTTP client instance with environment that has access
12 * credentials context. Use this instance to invoke PayPal APIs, provided the
13 * credentials have access.
14 */
15 public static function client()
16 {
17 return new PayPalHttpClient(self::environment());
18 }
19 /**
20 * Set up and return PayPal PHP SDK environment with PayPal access credentials.
21 * This sample uses SandboxEnvironment. In production, use LiveEnvironment.
22 */
23 public static function environment()
24 {
25 $clientId = getenv("CLIENT_ID") ?: "PAYPAL-CLIENT-ID";
26 $clientSecret = getenv("CLIENT_SECRET") ?: "PAYPAL-CLIENT-SECRET";
27 return new SandboxEnvironment($clientId, $clientSecret);
28 }
29}

See also