# PayPal

> This page is about FlutterFlow (the app builder you use by describing your app), not FlutterFlow Studio.

URL: https://docs.flutterflow.io/ffx/paypal

Connect PayPal with a Sandbox or Live app's client ID and secret, and then ask the agent for a PayPal checkout that captures the payment and checks it.

Use PayPal to take payments in your app with PayPal checkout. To connect, you need the client ID and secret of a REST app on PayPal's developer site. Start with a Sandbox app, which takes test payments.

## Connect PayPal {#connect-paypal}

On PayPal's developer site, open **Apps & Credentials**, and then copy the client ID and secret of an app on the **Sandbox** tab. FlutterFlow detects whether they belong to a Sandbox app or a Live app.

Only a project owner can connect PayPal. If you're a project owner, connect PayPal:

1. Open **Project Settings › Connections**, and then turn on the switch for **PayPal**.
2. In the **Connect PayPal** dialog, paste the client ID into **Client ID** and the secret into **Client secret**. **Find it** opens PayPal's developer site.
3. Click **Connect**.

See [Connect a service](https://docs.flutterflow.io/ffx/connect-a-service).

## What to ask

With PayPal connected, your app can start a checkout, send the customer to PayPal to approve the payment, capture the payment when PayPal sends them back, and read an order back. Nothing is charged until your app captures the payment. Ask for the checkout you want, and say what the customer pays for.

> Example request: "Add a Pay with PayPal button to the booking screen that charges the visit's price in USD. After the customer approves on PayPal, capture the payment and mark the booking paid only if the capture completed for the right amount."

> Example request: "Add PayPal checkout to the cart. When PayPal sends the customer back, capture the order and show a receipt, and if they cancel on PayPal, return them to the cart."

> Example request: "Read the PayPal order whose ID I provide, and tell me its status, the amount and currency, and whether the payment was captured."

## Agent questions

If PayPal isn't connected, the agent asks you to connect it in a card above the message box. See [Connect when the agent asks](https://docs.flutterflow.io/ffx/connect-a-service#connect-when-the-agent-asks).

If your PayPal connection is a live account, the agent asks an owner of the app to approve each PayPal call in a thread that owner started. See [Live payments](#live-payments).

## Review {#check-the-result}

After the agent finishes, read the turn's [**Summary**](https://docs.flutterflow.io/ffx/what-changed#summary) and review its [**Changes**](https://docs.flutterflow.io/ffx/what-changed#changes-tab). Check the affected screens in **Screens**, and try the change in **Preview**. If the change uses records or sign-in, test it with [the thread's own data in **Data**](https://docs.flutterflow.io/ffx/thread-data).

After you push a backend change, check the result in **Backend**.

A PayPal payment counts as paid only when its capture status is `COMPLETED`. A capture that's pending, declined, or failed isn't paid. Before your app treats an order as paid, check that the app reads the order back and compares the amount, the currency, and its own order reference with the order that it priced.

In the preview, PayPal's page opens, but the buyer comes back to your app's return page, not the preview. Try the whole payment on a phone build.

## Push

When the checkout works, [push the changes to your app](https://docs.flutterflow.io/ffx/push).

## Live payments {#live-payments}

To take real payments, use a Live app. To switch, replace the Sandbox credentials with the Live app's. If you're a project owner, click PayPal's menu in **Project Settings › Connections**, and then select **Replace client secret**.

A live connection shows **Live account**. Your preview and the agent take real payments with it, so use a Sandbox app while you build.

On a live account, every PayPal call that the agent makes in a thread that an owner of the app started waits on an **Approval** card, including calls that only read an order. That owner approves, and each approval runs one call. In a thread that anyone else started, the agent can't use a live PayPal account. See [Live payment accounts](https://docs.flutterflow.io/ffx/agent-permissions#live-money-accounts).

## Chat connections {#chat-connections}

**Account › Chat connections** also lists PayPal. That connection is separate: it's your own PayPal account, which the agent uses in threads that you start, and your app doesn't use it. See [Tools for the agent](https://docs.flutterflow.io/ffx/agent-tools).

## Next steps

- To replace the credentials or disconnect PayPal, see [Manage connections](https://docs.flutterflow.io/ffx/manage-connections).
- For other services your app can use, see [Available services](https://docs.flutterflow.io/ffx/services).

## Troubleshooting

If PayPal refuses the client ID and secret, copy both again from the same app under **Apps & Credentials**, on the **Sandbox** or **Live** tab. If your app can't capture or read an order, check that the order came from the same connection: a Sandbox connection can't read a Live order. For other connection problems, see [Troubleshoot connections](https://docs.flutterflow.io/ffx/troubleshoot-connections).
