On this page
No Headings
Last updated: June 11, 2026
You can accept Venmo for secure payments from US customers with the JavaScript SDK v6. This guide shows you how to set up your environment, review eligibility requirements, add Venmo payments, and work with advanced features.
Before beginning your integration, meet these requirements:
Note: You'll use your sandbox credentials to create a
.envfile during the Development setup.
Before continuing, complete the steps in the JavaScript SDK v6 sample integration README.
Once setup is complete, verify the JavaScript SDK v6 examples are running at http://localhost:8080.
To view the Venmo one-time payment example, navigate to: http://localhost:8080/client/components/venmoPayments/oneTimePayment/html/src/index.html.
Create your HTML page and include the PayPal SDK script.
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>One-Time Payment - Venmo - PayPal JavaScript SDK</title>
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
.buttons-container {
display: flex;
flex-direction: column;
gap: 12px;
}
</style>
</head>
<body>
<h1>One-Time Payment Venmo Integration</h1>
<div class="buttons-container">
<!-- Venmo button is initially hidden until eligibility is confirmed -->
<venmo-button id="venmo-button" type="pay" hidden></venmo-button>
</div>
<script src="app.js"></script>
<!-- Load PayPal SDK -->
<script
async
src="https://www.sandbox.paypal.com/web-sdk/v6/core"
onload="onPayPalWebSdkLoaded()"
></script>
</body>
</html>Set up the PayPal SDK with the Venmo component after it loads.
async function onPayPalWebSdkLoaded() {
try {
// Create PayPal SDK instance with Venmo component
const sdkInstance = await window.paypal.createInstance({
clientId: "YOUR_CLIENT_ID",
components: ["venmo-payments"],
pageType: "checkout",
});
// Check payment method eligibility
const paymentMethods = await sdkInstance.findEligibleMethods({
currencyCode: "USD",
});
// Only setup Venmo button if eligible
if (paymentMethods.isEligible("venmo")) {
setupVenmoButton(sdkInstance);
} else {
console.log("Venmo is not eligible for this session");
}
} catch (error) {
console.error("SDK initialization error:", error);
}
}Create the Venmo payment session and set up the button.
async function setupVenmoButton(sdkInstance) {
// Create Venmo payment session with callback options
const venmoPaymentSession = sdkInstance.createVenmoOneTimePaymentSession(
paymentSessionOptions,
);
// Get reference to the Venmo button element
const venmoButton = document.querySelector("#venmo-button");
// Show the button since Venmo is eligible
venmoButton.removeAttribute("hidden");
// Add click handler to start payment flow
venmoButton.addEventListener("click", async () => {
try {
// Start the payment session
await venmoPaymentSession.start(
{
presentationMode: "auto" // Auto-detects best presentation mode
},
createOrder() // Create order and return order details
);
} catch (error) {
console.error("Payment start error:", error);
handlePaymentError(error);
}
});
}Define callback handlers for payment approval, cancellation, and error scenarios.
const paymentSessionOptions = {
// Called when payment is approved by the user
async onApprove(data) {
console.log("Payment approved:", data);
try {
// Capture the order on your server
const orderData = await captureOrder({
orderId: data.orderId,
});
console.log("Payment captured successfully:", orderData);
// Handle successful payment (e.g., redirect, show success message)
handlePaymentSuccess(orderData);
} catch (error) {
console.error("Payment capture failed:", error);
handlePaymentError(error);
}
},
// Called when user cancels the payment
onCancel(data) {
console.log("Payment cancelled:", data);
// Handle cancellation (e.g., show message, return to cart)
handlePaymentCancellation();
},
// Called when an error occurs during payment
onError(error) {
console.error("Payment error:", error);
// Handle error (e.g., show error message, retry option)
handlePaymentError(error);
},
};The presentation mode determines how the payment UI appears for the customer.
// Auto mode - automatically chooses the best presentation mode
await venmoPaymentSession.start(
{ presentationMode: "auto" },
createOrder()
);Note: For Venmo,
"auto"is the only supported presentation mode.
The integration requires these server-side endpoints.
// POST /paypal-api/checkout/orders/create-with-sample-data
async function createOrder() {
const response = await fetch(
"/paypal-api/checkout/orders/create-with-sample-data",
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
},
);
const { id } = await response.json();
return { orderId: id };
}// POST /paypal-api/checkout/orders/{orderId}/capture
async function captureOrder({ orderId }) {
const response = await fetch(
`/paypal-api/checkout/orders/${orderId}/capture`,
{
method: "POST",
headers: {
"Content-Type": "application/json",
},
},
);
const data = await response.json();
return data;
}Integrate Venmo effectively by understanding the essential parts of the JavaScript SDK v6 workflow.
| Key component | Purpose | Details |
|---|---|---|
| PayPal SDK instance | Main entry point for PayPal functionality |
|
| Eligibility check | Determines if Venmo is available |
|
| Payment session | Manages Venmo payment flow and callbacks |
|
| Presentation modes | Defines how Venmo is displayed |
|