# Getting started

### How PayPal Checkout works

Integrate PayPal Checkout to give your customers payment buttons for PayPal, Venmo, debit, and credit cards.

PayPal's JavaScript SDK supports how you want to accept payments on your website. Our SDK handles displaying the buttons for PayPal and other payment methods, so your customers can pay with whatever method they choose. They can also use a pre-built form to pay directly using credit or debit.

## Checkout

PayPal Checkout helps you get set up quickly to accept PayPal and other payment methods. With expanded checkout you can customize the checkout to match your site's branding.

<table data-view="cards"><thead><tr><th></th><th></th><th data-hidden data-card-cover data-type="files"></th><th data-hidden data-card-target data-type="content-ref"></th></tr></thead><tbody><tr><td><strong>Integration Guide</strong></td><td>Implement PayPal Checkout server-side using Node.js, Python, and more.</td><td><a href="/files/PTgkghtnFKv02RzK4vwH">/files/PTgkghtnFKv02RzK4vwH</a></td><td><a href="/pages/OQzcjwrzzibKdquxDQMe">/pages/OQzcjwrzzibKdquxDQMe</a></td></tr><tr><td><strong>API Reference</strong></td><td>Use the Orders API to create, update, authorize, and capture orders.</td><td><a href="/files/ndqalWo7IdWarIIagSTY">/files/ndqalWo7IdWarIIagSTY</a></td><td><a href="/pages/U2bZSJ73tp3tbrZrcKEw">/pages/U2bZSJ73tp3tbrZrcKEw</a></td></tr><tr><td><strong>JavaScript SDK Reference</strong></td><td>Dynamically expose objects and methods based on the components you select.</td><td><a href="/files/n9iqJFZylpx3j5mtMXQC">/files/n9iqJFZylpx3j5mtMXQC</a></td><td><a href="/pages/wuwuZ2sppgE2GKv4XaPd">/pages/wuwuZ2sppgE2GKv4XaPd</a></td></tr></tbody></table>

### Integrating the Checkout client

The JavaScript payload shows up in the global window object under the `paypal` namespace, so you can access it anywhere in your app to render any component in the JavaScript SDK.

1. The `<script>` tag fetches the PayPal SDK when your checkout page renders.
2. When your customer clicks on a PayPal button, the `createOrder` callback tells your server to initiate an order with PayPal's server.
3. PayPal server sends the Order ID to your server, which then relays it to the SDK's `createOrder` callback, prompting the SDK to launch the checkout window for the Order ID.
4. The customer logs in using PayPal credentials and uses the order review page to verify order details and check out.
5. The `onApprove` callback launches after payment is confirmed.
6. You can use the response to verify the payment was completed or catch any errors about their payment method.

The PayPal buttons component shows up on your website based on the configuration you set in the JavaScript SDK. Your buyer can choose how to check out based on the eligible payment methods. A buyer following the PayPal Checkout flow sees the PayPal, Venmo, and Debit or Credit Card buttons.

When your buyer selects a payment method:

1. A pop-up shows up on the buyer's screen.
2. If the buyer is logged into their PayPal account, the pop-up includes details about their order.
3. This screen shows the buyer's default shipping address and the default shipping option you selected in the initial Orders API call.
4. The buyer can choose a different shipping address and payment method.
5. The buyer confirms that all the information is correct.
6. The buyer selects Complete Purchase to authorize the payment.
7. The order goes to PayPal's servers, where we process the payment.

### Set up your development environment

{% tabs %}
{% tab title="Node.js" %}
{% stepper %}
{% step %}

### Build the server

This sample Node.js integration uses the npm package manager. Enter:

```bash
npm install
```

to run the sample application. For more information, [visit npm's documentation.](https://www.npmjs.com)
{% endstep %}

{% step %}

### Install dependencies

Set up your integration by running:

```bash
npm install @paypal/paypal-server-sdk@1.0.0 dotenv express body-parser
```

to install the following 4 libraries at the same time:

* `@paypal/paypal-server-sdk@1.0.0` – The PayPal Server SDK provides integration access to the PayPal REST APIs
* `dotenv` – separates your configuration and code by loading environment variables from a `.env` file into `process.env`
* `express` – is a Node.js web application framework that supports web and mobile applications
* `body-parser` – is used to parse incoming request bodies in a middleware before your handlers

This sample integration uses PayPal's Server SDK v1.0.0. For more details, visit [the PayPal Server SDK documentation (login required)](https://developer.paypal.com).
{% endstep %}

{% step %}

### Verify `package.json`

The following code sample shows a `package.json` file for a PayPal integration. Replace `YOUR-SERVER-NAME.js` with the name of your server file in `main` and `start` on lines 5 and 8:

```json
{  
  "name": "paypal-checkout-integration-backend-node",  
  "version": "1.0.0",  
  "private": true,  
  "type": "module",  
  "dependencies": {  
    "@paypal/paypal-server-sdk": "^1.0.0",  
    "body-parser": "^1.20.3",  
    "dotenv": "^16.3.1",  
    "express": "^4.18.2"  
  },  
  "scripts": {  
    "server-dev": "nodemon server.js",  
    "start": "npm run server-dev",  
    "prod": "node server.js",  
    "format": "npx prettier --write **/*.{js,jsx,md}",  
    "format:check": "npx prettier --check **/*.{js,jsx,md}"  
  },  
  "devDependencies": {  
    "concurrently": "^8.2.1",  
    "nodemon": "^3.0.1"  
  }  
}
```

If you're having trouble with your app, reinstall your local library and package files using `npm install`. If you're getting the following node error, include `"type": "module"` in your `package.json` file. This line isn't automatically added when `package.json` is created.

{% hint style="warning" %}
**Warning:** To load an ES module, set `"type": "module"` in the package.json file or use the `.mjs` extension. Use `node --trace-warnings ...` to show where the warning was created. See line 5 of the sample `package.json` file for an example.
{% endhint %}
{% endstep %}

{% step %}

### Set up environment variables

Update your operating system's local working environment variables to pass your app's client ID and client secret securely. The following examples show how to set up these environment variables in PowerShell on Windows, as well as the Linux and MacOS operating systems:

**Windows (PowerShell):**

```powershell
$env:PAYPAL_CLIENT_ID = "<PAYPAL_CLIENT_ID>"
$env:PAYPAL_CLIENT_SECRET = "<PAYPAL_CLIENT_SECRET>"
```

**Linux / MacOS:**

```bash
export PAYPAL_CLIENT_ID="<PAYPAL_CLIENT_ID>"
export PAYPAL_CLIENT_SECRET="<PAYPAL_CLIENT_SECRET>"
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Java" %}
{% stepper %}
{% step %}

### Build the server

The sample Java integration uses the Maven package manager.

Run `mvn clean install` to build the server. Enter `mvn spring-boot:run` to start the sample application. For more information, visit [Java's documentation.](https://docs.oracle.com/en/java/)
{% endstep %}

{% step %}

### Install dependencies

This sample integration uses PayPal's Server SDK v1.0.0. For more details, visit [the PayPal Server SDK documentation](https://developer.paypal.com/serversdk) by logging in to your account.
{% endstep %}

{% step %}

### Verify `pom.xml`

The following code sample shows how to set up a pom.xml file for a PayPal integration:

```xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>3.3.2</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.paypal.sample</groupId>
    <artifactId>advanced-integration</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>PayPal Checkout Integration</name>
    <description>Sample Java demo application for PayPal JS SDK Integration</description>
    <url/>
    <licenses>
        <license/>
    </licenses>
    <developers>
        <developer/>
    </developers>
    <scm>
        <connection/>
        <developerConnection/>
        <tag/>
        <url/>
    </scm>
    <properties>
        <java.version>21</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-thymeleaf</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>
                com.paypal.sdk
            </groupId>
            <artifactId>
                paypal-server-sdk
            </artifactId>
            <version>
                1.0.0
            </version>
        </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
             </plugin>
        </plugins>
    </build>
</project>
```

{% endstep %}

{% step %}

### Set up environment variables

Update your operating system's local working environment variables to pass your app's client ID and client secret securely. The following examples show how to set up these environment variables in PowerShell on Windows, as well as the Linux and MacOS operating systems:

```
Windows (powershell)
    $env:PAYPAL_CLIENT_ID = "<PAYPAL_CLIENT_ID>"
    $env:PAYPAL_CLIENT_SECRET = "<PAYPAL_CLIENT_SECRET>"
Linux / MacOS
    export PAYPAL_CLIENT_ID="<PAYPAL_CLIENT_ID>"
    export PAYPAL_CLIENT_SECRET="<PAYPAL_CLIENT_SECRET>"
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="PHP" %}
{% stepper %}
{% step %}

### Build the server

This sample PHP integration uses the Homebrew package manager and Composer.

To install composer on macOS, run the command `brew install composer`. For Windows users, Composer can be downloaded from their [website](https://getcomposer.org/download/).

Use `composer start` to run the sample application. For more details, [visit composer's documentation.](https://getcomposer.org/)
{% endstep %}

{% step %}

### Install dependencies

Run `composer install` to add the dependencies you need to set up your PHP integration.

This sample integration uses PayPal's Server SDK v1.0.0. For more details, visit [the PayPal Server SDK documentation](https://developer.paypal.com/serversdk) by logging in to your account.
{% endstep %}

{% step %}

### Verify `composer.json`

The following code sample shows a composer.json file for a PayPal integration:

```json
{
    "description": "PayPal JS SDK Integration - Checkout Flow",
    "license": "MIT",
    "require": {
        "php": "^7.4 || ^8.0",
        "ext-json": "*",
        "paypal/paypal-server-sdk": "1.0.0"
    },
    "require-dev": {
    },
    "scripts": {
        "start": "php -S localhost:8080 -t src"
    },
    "config": {
    }
}
```

{% endstep %}

{% step %}

### Set up environment variables

Update your operating system's local working environment variables to pass your app's client ID and client secret securely. The following examples show how to set up these environment variables in PowerShell on Windows, as well as the Linux and MacOS operating systems:

```
Windows (powershell)
    $env:PAYPAL_CLIENT_ID = "<PAYPAL_CLIENT_ID>"
    $env:PAYPAL_CLIENT_SECRET = "<PAYPAL_CLIENT_SECRET>"

Linux / MacOS
    export PAYPAL_CLIENT_ID="<PAYPAL_CLIENT_ID>"
    export PAYPAL_CLIENT_SECRET="<PAYPAL_CLIENT_SECRET>"
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Python" %}
{% stepper %}
{% step %}

### Build the server

This sample Python integration uses the Flask package manager.

Run `python3 -m venv .venv` to build the server. Enter `flask --app server run` to start the sample application.
{% endstep %}

{% step %}

### Install dependencies

Run `pip install -r requirements.txt` to add the dependencies you need to set up your Python integration.

This sample integration uses PayPal's Server SDK v1.0.0. For more details, visit [the PayPal Server SDK documentation](https://developer.paypal.com/serversdk) by logging in to your account.
{% endstep %}

{% step %}

### Verify requirements

The following code sample shows a `requirements.txt` file for a PayPal integration:

```
Flask==3.0.3
paypal-server-sdk==1.0.0
```

{% endstep %}

{% step %}

### Set up environment variables

Update your operating system's local working environment variables to pass your app's client ID and client secret securely. The following examples show how to set up these environment variables in PowerShell on Windows, as well as the Linux and MacOS operating systems:

```
Windows (powershell)
    $env:PAYPAL_CLIENT_ID = "<PAYPAL_CLIENT_ID>"
    $env:PAYPAL_CLIENT_SECRET = "<PAYPAL_CLIENT_SECRET>"
    
Linux / MacOS
    export PAYPAL_CLIENT_ID="<PAYPAL_CLIENT_ID>"
    export PAYPAL_CLIENT_SECRET="<PAYPAL_CLIENT_SECRET>"
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title="Ruby" %}
{% stepper %}
{% step %}

### Build the server

This sample Ruby integration uses the Sinatra package manager.

Enter `bundle exec ruby server.rb` to run the sample application.
{% endstep %}

{% step %}

### Install dependencies

Run `bundle install` to add the dependencies you need to set up your Ruby integration.

This sample integration uses PayPal's Server SDK v1.0.0. For more details, visit [the PayPal Server SDK documentation](https://developer.paypal.com/serversdk) by logging in to your account.
{% endstep %}

{% step %}

### Verify Gemfile

The following code sample shows the Gemfile for a PayPal integration:

```ruby
# frozen_string_literal: true

source "https://rubygems.org"

gem "paypal-server-sdk", "~> 1.0.0"
gem "puma", "~> 6.4"
gem "rackup", "~> 2.1"
gem "sinatra", "~> 4.0"
gem "sinatra-contrib", "~> 4.0"
```

{% endstep %}

{% step %}

### Set up environment variables

Update your operating system's local working environment variables to pass your app's client ID and client secret securely. The following examples show how to set up these environment variables in PowerShell on Windows, as well as the Linux and MacOS operating systems:

```
Windows (powershell)
    $env:PAYPAL_CLIENT_ID = "<PAYPAL_CLIENT_ID>"
    $env:PAYPAL_CLIENT_SECRET = "<PAYPAL_CLIENT_SECRET>"
    
Linux / MacOS
    export PAYPAL_CLIENT_ID="<PAYPAL_CLIENT_ID>"
    export PAYPAL_CLIENT_SECRET="<PAYPAL_CLIENT_SECRET>"
```

{% endstep %}
{% endstepper %}
{% endtab %}

{% tab title=".NET" %}
{% stepper %}
{% step %}

### Build the server

This sample .NET integration uses the dotnet package manager.&#x20;

Run `dotnet restore` to build the server. Enter `dotnet run` to start the sample application. For more information, visit [.NET's documentation.](https://learn.microsoft.com/en-us/dotnet/)
{% endstep %}

{% step %}

### Install dependencies

This sample integration uses PayPal's Server SDK v1.0.0. For more details, visit [the PayPal Server SDK documentation](https://developer.paypal.com/serversdk) by logging in to your account.
{% endstep %}

{% step %}

### Verify `.csproj` file

The following code sample shows a PayPalCheckoutIntegration.csproj file for a PayPal integration:

```aspnet
<Project Sdk="Microsoft.NET.Sdk.Web">
    <PropertyGroup>
        <TargetFramework>net8.0</TargetFramework>
        <RootNamespace>PayPalCheckoutIntegration</RootNamespace>
    </PropertyGroup>
    <ItemGroup>
        <PackageReference Include="Microsoft.AspNetCore.Mvc.NewtonsoftJson" Version="7.0.9" />
        <PackageReference Include="PayPalServerSDK" Version="1.0.0" />
    </ItemGroup>
</Project>
```

{% endstep %}

{% step %}

### Set up environment variables

Update your operating system's local working environment variables to pass your app's client ID and client secret securely. The following examples show how to set up these environment variables in PowerShell on Windows, as well as the Linux and MacOS operating systems:

```
Windows (powershell)
    $env:PAYPAL_CLIENT_ID = "<PAYPAL_CLIENT_ID>"
    $env:PAYPAL_CLIENT_SECRET = "<PAYPAL_CLIENT_SECRET>"
    
Linux / MacOS
    export PAYPAL_CLIENT_ID="<PAYPAL_CLIENT_ID>"
    export PAYPAL_CLIENT_SECRET="<PAYPAL_CLIENT_SECRET>"
```

{% endstep %}
{% endstepper %}
{% endtab %}
{% endtabs %}

{% hint style="info" %}
View your client ID and client secret in the **PayPal Developer Dashboard** under *Apps & Credentials*.
{% endhint %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://paypal.gitbook.com/online-payments/getting-started.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
