> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aiwa.codes/llms.txt
> Use this file to discover all available pages before exploring further.

# PayPal

> Connect PayPal to accept PayPal, Pay Later, and card payments, and PayPal subscriptions, in the checkout flows you build with AIWA.

The PayPal connector lets applications you build with AIWA accept payments through PayPal.

You can use PayPal for:

* A PayPal button at checkout
* One-time payments for orders, bookings, and tickets
* Pay Later, where the buyer is eligible
* Card payments through the PayPal button
* Monthly subscriptions
* Testing everything with sandbox accounts before real money moves

**Connect PayPal. Describe what customers pay for. AIWA builds the checkout.**

## PayPal vs Stripe

Both connectors accept payments. Many products use one; some offer both.

| You want to | Use |
| - | - |
| Let customers pay with their PayPal balance or Pay Later | PayPal |
| A card checkout hosted by your payment provider | Stripe |
| Offer customers a choice at checkout | Both |

If you ask for payments without naming a provider, AIWA uses the payment connectors you've connected. To be sure, name PayPal in your request.

## Before You Start

You'll need:

* A PayPal account to sign in to the PayPal developer dashboard
* A PayPal Business account when you're ready to accept real payments

You can build and test everything with sandbox credentials first.

## Connect PayPal to AIWA

**1. Open the PayPal developer dashboard**

Sign in at developer.paypal.com with your PayPal account.

**2. Select Sandbox**

Open Apps & Credentials and make sure the Sandbox toggle is selected.

**3. Open an app**

Open the Default Application, or click "Create App" and name it after your project.

**4. Copy your credentials**

Copy the Client ID and the Secret.

**5. Connect in your project**

Open your AIWA project, go to Connectors, and select PayPal. Paste the Client ID and the Secret, and set Mode to sandbox.

You can also set a Currency. Use your PayPal account's main currency: a payment in another currency can wait in your PayPal account until you accept it by hand. If you leave it empty, prices are in US dollars (USD).

Once connected, the connector page checks your credentials with PayPal. If they belong to the other mode, it tells you which Mode to choose.

> [!WARNING]
>
> Your PayPal Secret is sensitive. Add it through the connector page, never in a prompt or in your application's frontend code.

## Test with Sandbox Accounts

In sandbox mode, no real money moves.

To pay in your preview, sign in to the PayPal window with a sandbox buyer account, not your real PayPal login. You'll find one in the PayPal developer dashboard under Testing Tools, then Sandbox Accounts.

While your app runs in sandbox mode, its checkout says so, and tells you which login to use.

## Your First PayPal Checkout

Suppose you sell tickets for an event.

Tell AIWA:

> Let visitors buy tickets for my event with PayPal. Show the ticket type and price, add a PayPal button, and email the buyer their ticket after payment.

The workflow might look like:

```text theme={null}
Visitor chooses ticket
        ↓
Order created
        ↓
PayPal button
        ↓
Buyer approves
        ↓
Payment captured on the server
        ↓
Order marked paid
```

The PayPal button shows PayPal, Pay Later, and card options, depending on what the buyer is eligible for.

## How Payment Is Confirmed

An order is only marked paid when your app's server has captured the payment with PayPal and PayPal reports it as completed.

Reaching a success page in the browser isn't proof of payment, so your app never relies on it.

Your app doesn't need webhooks for this. The capture answers straight away, so the confirmation happens in the same request.

If the buyer closes the page halfway through, your app can pick up the same order rather than creating a new one, so nobody pays twice.

## Subscriptions

PayPal can also charge a monthly subscription.

For example:

> Charge a monthly PayPal subscription for the Pro plan at \$29. Only active subscribers can open the reports page.

Conceptually:

```text theme={null}
Choose plan
     ↓
PayPal subscription
     ↓
Buyer approves
     ↓
Status checked
     ↓
Access granted
```

Your app checks the subscription with PayPal before granting access, and again regularly afterwards:

* Only an active subscription unlocks paid features.
* A subscription cancelled or suspended in PayPal loses access, even if the customer never returns to your app.
* If PayPal can't be reached, the customer is asked to try again rather than given access.

## Go Live

When you're ready for real customers:

1. Switch the toggle in the PayPal developer dashboard to Live. This needs a PayPal Business account.
2. Copy the live Client ID and Secret.
3. Paste them on the PayPal connector page and set Mode to live.
4. Make a small real payment to confirm the whole flow.

Refunds and disputes are handled in your PayPal account.

## Common Problems

### PayPal says the credentials belong to the other mode

Sandbox and live credentials are different. Set Mode to match where you copied them from, or paste the credentials for the mode you want.

### PayPal rejects the Client ID and Secret

Check that both were copied in full from the same app in the PayPal developer dashboard, and that the app hasn't been deleted.

### You can't log in to the PayPal window in your preview

In sandbox mode, use a sandbox buyer account from Testing Tools, then Sandbox Accounts. Your real PayPal login only works in live mode.

### A payment is waiting in PayPal

The payment was in a currency your PayPal account doesn't hold. Accept it in your PayPal account, and set the Currency on the connector page to your account's main currency.

### A subscriber lost access

Check the subscription's status in your PayPal account. Only an active subscription unlocks paid features.

## Debugging PayPal

A good Debug Mode request might look like:

> Expected: After a buyer approves the PayPal payment, the order should be marked paid and the ticket emailed.
>
> Actual: The buyer approves the payment, but the order stays pending.
>
> PayPal shows as connected in sandbox mode.
>
> Error: \[PASTE ERROR IF AVAILABLE]
>
> Debug the PayPal capture without changing the ticket selection.

Never paste your PayPal Secret into a prompt.

## Test Your PayPal Workflow

Before publishing, test:

* A successful payment with a sandbox buyer account
* A cancelled payment
* Refreshing the page during checkout
* The order status after payment
* Confirmation emails
* Subscribing, cancelling, and losing access
* The correct currency and amounts
* The checkout on mobile

## A Good PayPal Prompt

A strong request defines:

* **Product:** What is the customer paying for?
* **Price:** How much, and in which currency?
* **Type:** One-time payment or subscription?
* **After payment:** What should happen once it's confirmed?
* **Access:** What does a paying customer unlock?

For example:

> Add a PayPal checkout to the booking page. Charge the price of the selected session in GBP, mark the booking paid only after the payment is captured, and email the customer a confirmation. If the payment is cancelled, keep the booking as unpaid and let the customer try again.

That's significantly stronger than:

> Add PayPal.

## Next: Resend

PayPal handles payments.

Next, we'll connect your application to Resend so it can communicate with users through transactional email.

> **[Resend](/integrations/resend.md)**
>
> Connect Resend and send transactional email from your AIWA app.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.