Payouts SDK and APIs reference
You can add PayPal Payouts to your application in two ways:
Payouts SDK
Payouts SDK lets you add PayPal Payouts to your server app with less code. It handles authentication, API calls, and errors for you. The SDK is available for PHP, Java, .NET, and Python.
With the SDK, you can:
- Call Payouts APIs
- Manage authentication
- Handle API responses
Note: The SDK is for server-side use only.
To get started:
Install the SDK
Install the Payouts SDK for your language:
- PHP
- Java
- Python
- .NET
composer require paypal/paypal-payouts-sdk ~1.0.0
<dependency>
<groupId>com.paypal.sdk</groupId>
<artifactId>payouts-sdk</artifactId>
<version>1.0.2</version>
</dependency>
pip install paypal-payouts-sdk
dotnet add package PayPalCheckoutSdk.Payouts
Configure your PayPal credentials
Set up your PayPal client ID and secret for authentication:
- PHP
- Java
- Python
- .NET
use PayPal\Core\PayPalHttpClient;
use PayPal\Core\SandboxEnvironment;
class PayPalClient {
public static function client() {
return new PayPalHttpClient(self::environment());
}
public static function environment() {
$clientId = getenv("CLIENT_ID") ?: "PAYPAL-CLIENT-ID";
$clientSecret = getenv("CLIENT_SECRET") ?: "PAYPAL-CLIENT-SECRET";
return new SandboxEnvironment($clientId, $clientSecret);
}
}
PayPalEnvironment environment = new PayPalEnvironment.Sandbox(
"CLIENT_ID",
"CLIENT_SECRET"
);
PayPalHttpClient client = new PayPalHttpClient(environment);
from paypalcheckoutsdk.core import PayPalHttpClient, SandboxEnvironment
environment = SandboxEnvironment(client_id="CLIENT_ID", client_secret="CLIENT_SECRET")
client = PayPalHttpClient(environment);
var environment = new SandboxEnvironment("CLIENT_ID", "CLIENT_SECRET");
var client = new PayPalHttpClient(environment);
Note: Use
SandboxEnvironment
for testing andLiveEnvironment
for production. Learn how to get your REST API credentials for sandbox and live environments in the Developer Dashboard.
Send and manage payouts
Send a payout
Use the SDK to create a payout batch:
- PHP
- Java
- Python
- .NET
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" => "[email protected]",
"note" => "Thanks for your service!",
"sender_item_id" => "item_001"
]
]
];
$response = $client->execute($request);
PayoutsPostRequest request = new PayoutsPostRequest();
request.requestBody(new HashMap<String, Object>() {{
put("sender_batch_header", new HashMap<String, Object>() {{
put("sender_batch_id", "batch_001");
put("email_subject", "You have a payout!");
}});
put("items", Arrays.asList(new HashMap<String, Object>() {{
put("recipient_type", "EMAIL");
put("amount", new HashMap<String, Object>() {{
put("value", "10.00");
put("currency", "USD");
}});
put("receiver", "[email protected]");
put("note", "Thanks for your service!");
put("sender_item_id", "item_001");
}}));
}});
client.execute(request);
from paypalcheckoutsdk.payouts import PayoutsPostRequest
request = PayoutsPostRequest()
request.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" => "[email protected]",
"note" => "Thanks for your service!",
"sender_item_id" => "item_001"
}
]
})
response = client.execute(request)
var request = new PayoutsPostRequest();
request.RequestBody = new {
sender_batch_header = new {
sender_batch_id = "batch_001",
email_subject = "You have a payout!"
},
items = new[] {
new {
recipient_type = "EMAIL",
amount = new {
value = "10.00",
currency = "USD"
},
receiver = "[email protected]",
note = "Thanks for your service!",
sender_item_id = "item_001"
}
}
};
var response = await client.Execute(request);
Check payout status
To check the status of a payout, use the payout batch ID:
- PHP
- Java
- Python
- .NET
use PayPal\Payouts\PayoutsGetRequest;
$request = new PayoutsGetRequest("batch_001");
$response = $client->execute($request);
$status = $response->result->batch_header->batch_status;
echo $status;
PayoutsGetRequest request = new PayoutsGetRequest("batch_001");
HttpResponse<PayoutBatch> response = client.execute(request);
String status = response.result().batchHeader().batchStatus();
System.out.println(status);
from paypalcheckoutsdk.payouts import PayoutsGetRequest
request = PayoutsGetRequest("batch_001")
response = client.execute(request)
status = response.result["batch_header"]["batch_status"]
print(status)
var request = new PayoutsGetRequest("batch_001");
var response = await client.Execute(request);
Use Payouts APIs
You can also use the Payouts APIs directly. This method gives you control over HTTP requests, authentication, and error handling. Use this approach if you need advanced or custom integration.
The following APIs are available for Payouts integration:
- Generate access token:
POST /v1/oauth2/token
- Create payout batch:
POST /v1/payments/payouts
- Track status:
GET /v1/payments/payouts/{id}
For more information and detailed steps, see [Use Payouts APIs]/docs/send-payouts/send-money/use-payouts-apis).