Skip to main content

Payouts SDK and APIs reference

The Payouts SDK is a set of libraries that help you add PayPal Payouts to your server application. It works with Node.js, Java, .NET, and Python. You cannot use it in browsers or on the client side.

With the SDK, you can:

  • Call Payouts APIs quickly.
  • Manage authentication automatically.
  • Handle API responses easily.

If you use the Payouts API directly, you must write code for HTTP requests, authentication, and error handling. The SDK simplifies this work. It follows best practices and keeps up with API changes. You write less code and get clear examples for each language.

Note: The SDK is updated regularly to support new API features. For advanced or highly customized needs, you may want to use the API directly for greater flexibility.

Get started

To get started:

  1. Install the SDK for your language.
  2. Configure your PayPal credentials.
  3. Send and manage payouts.

Install the SDK

Install the Payouts SDK for your language:

composer require paypal/payouts-sdk

Configure your PayPal credentials

Set up your PayPal client ID and secret for authentication:

use PayPal\Core\PayPalHttpClient;
use PayPal\Core\SandboxEnvironment;

$clientId = "CLIENT_ID";
$clientSecret = "CLIENT_SECRET";
$environment = new SandboxEnvironment($clientId, $clientSecret);
$client = new PayPalHttpClient($environment);

Send and manage payouts

Send a payout

Use the SDK to create a payout batch:

use PayPal\Payouts\PayoutsPostRequest;

$request = new PayoutsPostRequest();
$request->body = [
"sender_batch_header" => [
"sender_batch_id" => "batch_001",
"email_subject" => "You have a payout!"
],
"items" => [
[
"recipient_type" => "EMAIL",
"amount" => [
"value" => "10.00",
"currency" => "USD"
],
"receiver" => "recipient@example.com",
"note" => "Thanks for your service!",
"sender_item_id" => "item_001"
]
]
];

$response = $client->execute($request);

Check payout status

To check the status of a payout batch, use the batch ID returned when you created the payout:

use PayPal\Payouts\PayoutsGetRequest;

$request = new PayoutsGetRequest("batch_001");
$response = $client->execute($request);
$status = $response->result->batch_header->batch_status;
echo $status;

Error handling

The SDK throws exceptions for errors such as invalid requests or authentication failures. Catch and inspect the exception to handle errors appropriately:

try {
$response = $client->execute($request);
} catch (HttpException $ex) {
echo $ex->statusCode;
echo $ex->getMessage();
}