Skip to main content
Accept PayPal payments on your website with the minimum amount of code required. You might use this ultra light integration as a proof of concept, basic e-commerce checkout, or simple donation form. This integration creates an order and captures a payment. It uses PayPal’s JavaScript SDK on the client side and server SDK on the server side. The JavaScript SDK renders the PayPal button and handles the UI. The server SDK creates and captures orders with your app credentials.

Eligibility

This integration works everywhere PayPal is available.

Prerequisites

  • Create a PayPal developer account.
  • Get a client ID and secret.
  • (Optional) Enable negative testing in the developer dashboard:
    1. Go to Dashboard > Sandbox > Accounts.
    2. Select on your sandbox business account and select View/Edit.
    3. Enable Negative Testing and save.

Create project structure

Choose your preferred language and set up the project structure.

Set up back end

Choose your preferred language and copy the code into your server file:

Set up front end

Open the public/index.html file in a code editor and copy and paste the following code. Replace YOUR_CLIENT_ID with the client ID created in the prerequisites.
If your app uses PayPal buttons across multiple pages or a modular JavaScript architecture, see Multipage and modular app issues.

Set your client ID and secret

Open the .env file in a code editor and replace your_sandbox_client_id and your_sandbox_secret with the client ID and secret you created for your app in the prerequisites.

Run the application locally

Start the server:
Open the following URL in your browser. You should see a PayPal button.
Don’t see the button?

Best practices

Use the following best practices to ensure secure, reliable, and maintainable integrations when building your checkout experience.
  • Start minimal and expand later: This code works in production. Add features as needed.
  • Use environment variables: Never hardcode credentials. Keep the .env file out of Git.
  • Create orders on the server: Never create orders in the browser due to security risks. Always use the server.
  • Test in sandbox first: Use sandbox accounts to test payments before going live.
  • Store transaction IDs: Save capture IDs for refunds, disputes, and record keeping.

Test your integration

Before testing, make sure you have sandbox account credentials for both buyer and seller roles. Get sandbox account credentials.

Standard testing

Use the following standard test scenarios to verify your checkout handles key outcomes.

Negative testing

Negative testing works only in sandbox mode. It is automatically disabled when NODE_ENV=production.For negative testing:
  1. Make sure to enable negative testing in your sandbox business account as described in the prerequisites.
  2. In the .env file, set ENABLE_NEGATIVE_TESTING=true and set NEGATIVE_TEST_TYPE to one of the error codes in the table.
  3. Restart the server after changing the .env file: node server.js.

Go-live checklist

  • Test all scenarios in the sandbox.
  • In the .env file:
    • Comment out the development section.
    • Uncomment the production section.
  • Update HTML client ID to production.
  • Add the HTTPS certificate.
  • Test with real $1 transaction.
  • Verify funds are received in your PayPal account.

Post-launch monitoring

These values are suggested monitoring thresholds for your integration, not performance guarantees from PayPal.

References

Next steps

The following use cases are common next steps after completing this quick start.