On this page
No Headings
Last updated: August 17, 2026
Important: PayPal supports these Checkout integrations:
checkout.js. Valid before February 2019. Customers who use checkout.js can access reference and support material in this Checkout guide. However, PayPal does not update checkout.js with new features and enhancements.A PayPal Checkout server integration makes calls from your server to the PayPal API. A server integration provides greater flexibility in the types of payments you can set up and execute. For example, with a PayPal Checkout server integration you can immediately authorize funds in a buyer's account and capture the payment later, set up recurring billing, issue refunds, and so on. This integration is well-suited for large merchants and partners.
Note: This guide shows you how to upgrade your existing client integration to a server integration by swapping out the calls that set up and execute payments.
The following diagrams show you how a server integration works with the PayPal API to set up and execute payments.
Tip: Try making test calls with the interactive API Executor.
The server integration upgrade includes these steps:
In this step, modify your existing client-side code to call your server to set up and execute the payment.
To set up your payment, follow these steps along with the corresponding comments in the example code.
payment callback function to the button, which is called when a buyer clicks the button.payment callback function, call actions.request.post() with your server URL.res.id from the response with the Payment ID returned from your server.To execute the payment, follow these steps with the corresponding comments in the example code.
onAuthorize callback function to the button, which is called after the buyer authorizes the payment on PayPal.onAuthorize callback, call actions.request.post() with your server URL, and pass the data.paymentID and data.payerID parameters to the server.<script src="https://www.paypalobjects.com/api/checkout.js"></script>
<div id="paypal-button"></div>
<script>
paypal.Button.render(
{
env: "sandbox", // Or 'production'
// Set up the payment:
// 1. Add a payment callback
payment: function (data, actions) {
// 2. Make a request to your server
return actions.request
.post("/my-api/create-payment/")
.then(function (res) {
// 3. Return res.id from the response
return res.id;
});
},
// Execute the payment:
// 1. Add an onAuthorize callback
onAuthorize: function (data, actions) {
// 2. Make a request to your server
return actions.request
.post("/my-api/execute-payment/", {
paymentID: data.paymentID,
payerID: data.payerID,
})
.then(function (res) {
// 3. Show the buyer a confirmation message.
});
},
},
"#paypal-button",
);
</script>In this step, you'll add your REST API credentials to your server, and then set up the server to call the PayPal API to set up and execute the payment.
Note: The following code example uses Node.js, but you can use any web platform or language to call the PayPal API. To install node, see Node.js downloads.
In the CLIENT and SECRET variables, add your sandbox client ID and secret. For testing purposes, these variables are automatically entered for you in the example code.
To set up your payment, follow these steps along with the corresponding comments in the example code.
/v1/payments/payment REST API with your client ID and secret and your payment details to create a payment ID.Note: For available options, see Set up a payment in the Integration Guide or the Create payment method in the Payments API reference.
Tip: Make test calls to the API using the interactive API Executor.
To execute the payment, follow these steps along with the corresponding comments in the example code.
paymentID and the payerID from the request body./v1/payments/payment/PAY-XXX/execute REST API with your client ID and secret, payer ID, and the payment ID. Pass any updated values, such as total, shipping, tax, and so on.Note: For available options, and the full list of payment details returned by actions.payment.execute(), see Execute payment in the Payments API reference.
var express = require("express");
var request = require("request");
// Add your credentials:
// Add your client ID and secret
var CLIENT =
"AUJoKVGO3q1WA1tGgAKRdY6qx0qQNIQ6vl6D3k7y64T4qh5WozIQ7V3dl3iusw5BwXYg_T5FzLCRguP8";
var SECRET =
"EOw8LNwDhM7esrQ3nHfzKc7xiWnJc83Eawln4YLfUgivfx1LGzu9Mj0F5wlarilXDqdK9Q5aHVo-VGjJ";
var PAYPAL_API = "https://api-m.sandbox.paypal.com";
express()
// Set up the payment:
// 1. Set up a URL to handle requests from the PayPal button
.post("/my-api/create-payment/", function (req, res) {
// 2. Call /v1/payments/payment to set up the payment
request.post(
PAYPAL_API + "/v1/payments/payment",
{
auth: {
user: CLIENT,
pass: SECRET,
},
body: {
intent: "sale",
payer: {
payment_method: "paypal",
},
transactions: [
{
amount: {
total: "5.99",
currency: "USD",
},
},
],
redirect_urls: {
return_url: "https://example.com",
cancel_url: "https://example.com",
},
},
json: true,
},
function (err, response) {
if (err) {
console.error(err);
return res.sendStatus(500);
}
// 3. Return the payment ID to the client
res.json({
id: response.body.id,
});
},
);
})
// Execute the payment:
// 1. Set up a URL to handle requests from the PayPal button.
.post("/my-api/execute-payment/", function (req, res) {
// 2. Get the payment ID and the payer ID from the request body.
var paymentID = req.body.paymentID;
var payerID = req.body.payerID;
// 3. Call /v1/payments/payment/PAY-XXX/execute to finalize the payment.
request.post(
PAYPAL_API + "/v1/payments/payment/" + paymentID + "/execute",
{
auth: {
user: CLIENT,
pass: SECRET,
},
body: {
payer_id: payerID,
transactions: [
{
amount: {
total: "10.99",
currency: "USD",
},
},
],
},
json: true,
},
function (err, response) {
if (err) {
console.error(err);
return res.sendStatus(500);
}
// 4. Return a success response to the client
res.json({
status: "success",
});
},
);
})
.listen(3000, function () {
console.log("Server listening at http://localhost:3000/");
});
// Run `node ./server.js` in your terminalFor information on setting up payment notifications, see Webhooks.
Next, test your button in the sandbox.
To test your server upgrade, run several test transactions and verify them in the sandbox.
Complete a test transaction:
Verify your test transactions from both the merchant's and buyer's perspective:
When your test is complete and you're satisfied with the results, you're ready to launch your new button into production.
To launch your button into production, you'll replace the sandbox credentials with live credentials in your script, and then run and verify a live transaction.
To generate REST API credentials for the live environment:
Enter your live client ID and secret into the code. Under paypal.Button.render():
env to production.var express = require('express');
var request = require('request');
// Add your credentials:
// Add your client ID and secret
var CLIENT = //Enter your live client ID;
var SECRET = //Enter your secret;
var PAYPAL_API = 'https://api-m.sandbox.paypal.com';Change the PAYPAL_API endpoint to: https://api-m.paypal.com.
Complete a live transaction:
To ensure your checkout flow correctly handles funding source errors, add a redirect that enables your buyer to choose an alternate funding source. For more information, see Manage funding source failure. To complete negative testing, see Negative Testing for REST API.
Verify your live transactions from both the merchant's and buyer's perspective:
Congratulations. You have completed the server upgrade for your PayPal Checkout integration.
With a PayPal Checkout server integration, you can make advanced payments by calling the REST APIs directly from your server. For more information, see:
You can optionally implement PayPal Checkout customization options and best practices tips: