PayPal - JavaScript frontend



by
Jeremy Canfield |
Updated: October 19 2025
| PayPal articles
First and foremost, it's important to understand that the PayPal SDK uses a client/server model, where the client is the frontend and the server is the backend.

For example, the frontend client could look something like this, where the data gathered in the frontend is then passed onto and processed by the backend.

For example, let's say you have the following HTML file.
<!DOCTYPE html>
<html>
<head></head>
<body>
<div id="paypal-button-container" class="paypal-button-container"></div>
<p id="result-message"></p>
<script src="https://www.paypal.com/sdk/js?client-id={{paypal_client_id}}&buyer-country=US¤cy=USD&components=buttons"></script>
<script src="paypal_frontend.js"></script>
</body>
</html>
Notice the HTML page expects a JavaScript file named paypal_frontend.js in the same directory as the HTML file. Let's say paypal_frontend.js has the following.
window.paypal
.Buttons({
style: {
shape: "rect",
layout: "vertical",
color: "gold",
label: "paypal",
},
message: {
amount: 100,
},
}).render("#paypal-button-container");
function resultMessage(message) {
const container = document.querySelector("#result-message");
container.innerHTML = message;
}
Navigating to your HTML page should return something like this.

Did you find this article helpful?
If so, consider buying me a coffee over at 