Skip to main content
With PayPal’s JavaScript SDK v6, you can accept basic card and debit card processing without requiring payers to log in or create a PayPal account. You’ll set up a test environment, add the needed frontend and backend, and then launch your standalone payment button in both sandbox and production.

Prerequisites

Before beginning your integration, meet these requirements:
  • Create a PayPal Developer account.
  • Create a PayPal app in the Apps & Credentials section of your account.
  • Use the Sandbox environment for testing.
  • Note your Client ID and Secret for server configuration.

Development setup

Before you run the integration locally, complete both server and client setup.

Server set up

  1. Navigate to your demo directory and instal dependencies:
  1. Create environment configuration:
  1. Start the server:
To load the application, see http://localhost:8080.

Client set up

  1. Navigate to the demo directory:
  1. Install dependencies:
  1. Start development server:
To load the application, see http://localhost:3000.

Integration patterns

The v6 SDK supports a variety of standalone payment button integration flows. The following patterns help you tailor the user experience for different requirements.

Standard button

Use the standard button implementation for payers to select a button to start the standalone payment button flow (Recommended).
  • File: html/src/recommended/app.js

HTML setup

Auto-start on load

Use the auto-start on load integration to automatically initiate the standalone payment button.
  • File: html/src/onload/app.js

Shipping callbacks

Use the shipping callback integration to handle address validation and shipping option changes.
  • File: html/src/shipping/app.js

Sample order creation with shipping options

Implementation support functions

These helper functions allow the client to interact with your backend for token generation, order creation, and payment capture.

Get client token

Create order

Capture order

Callback functions

Define the callback functions to handle key events during the standalone payment button flow, such as approvals, cancellations, errors, and warnings.

Required callbacks

The data argument to onWarn will always have the following shape:
When the onWarn callback executes, the buyer has encountered an error after they pressed the form submit button. These errors could include card failures, first/last name formatting errors, or address errors.

Start options

When starting a payment session, you can configure presentation mode.

API endpoints

Your backend server must provide these endpoints:
  • GET /paypal-api/auth/browser-safe-client-token - Returns client token for SDK initialization
  • POST /paypal-api/checkout/orders/create-with-sample-data - Creates PayPal order with sample data
  • POST /paypal-api/checkout/orders/create - Creates PayPal order with custom data
  • POST /paypal-api/checkout/orders/{order-id}/capture - Captures the authorized payment

Testing

See the steps for running and validating your integration.
  1. Ensure both server and client are running.
  2. Navigate to the demo page.
  3. Use PayPal Sandbox test accounts.
  4. Test all three integration patterns:
    • Standard button
    • Auto-start on load
    • Shipping callbacks

Best practices

  • Error handling: Always wrap PayPal API calls in try-catch blocks.
  • Eligibility check: Call findEligibleMethods() to determine available payment options.
  • Security: Never expose client secrets in frontend code, and use client tokens.
  • User experience: Choose the most suitable presentation mode for your use case.
  • Validation: Validate shipping callbacks if needed.
  • Testing: Test thoroughly in PayPal Sandbox before going live.

Troubleshooting

Quick solutions for common issues:
  • SDK load errors: Ensure the JavaScript SDK v6 script loads before onPayPalWebSdkLoaded().
  • Client token issues: Verify server endpoints are running and accessible.
  • Eligibility issues: Check that your standalone payments are enabled in PayPal app settings.
  • CORS errors: Confirm proper CORS configuration between client and server.