# Take online payments with PayPal

Connect a PayPal Business account so customers — often international visitors — can pay for bookings with PayPal. PayPal does not take rand, so PiGi charges in US dollars at your own exchange rate. You need the Client ID and Client Secret of a REST API app from the PayPal Developer Dashboard.

Source: https://help.pigi.io/guides/integrations/payments/paypal

## Quick answers

**What does PiGi need from PayPal?**
Two values, both required: the **Client ID** and the **Client Secret** of a REST API
app in your PayPal Developer Dashboard. Sandbox and live apps have different pairs.

**Where do I find my PayPal Client ID and Client Secret?**
Log in to the PayPal Developer Dashboard (developer.paypal.com), select **Apps &
Credentials**, and open your app under **REST API apps** — new accounts have a
**Default Application**, or select **Create App**. Copy the client ID and client
secret.

**Do I need a PayPal Business account?**
Yes, to take real payments. PayPal requires a Business account to go live. A developer
account is enough to test in sandbox.

**Can customers pay in rand with PayPal?**
No — PayPal does not take rand. PiGi charges the customer in US dollars, converting
the booking amount at the ZAR → USD rate you set under Finance → Currency rates. The
booking itself stays in rand. Without that rate, PayPal payments fail with "No ZAR→USD
exchange rate is set, so this payment can't be converted."

**Do I need to set up webhooks in PayPal?**
No. PiGi completes the PayPal payment when the customer returns from PayPal to
PiGi's page.

**Can I refund a PayPal payment from PiGi?**
Yes — in full or in part, for payments made through PiGi's online checkout. Switch on
**Enable Programmatic Refunds** under the gateway's **Refunds** row. The refund goes
back in US dollars at the rate used for the original charge, so a full refund returns
exactly what the customer paid.

**A customer says they paid with PayPal but the booking is unpaid. Why?**
PiGi takes the money when the customer comes back from PayPal. If they approved the
payment and closed the page before returning, PayPal does not charge them and the
booking stays unpaid. Ask them to pay again.

## What this does

Connecting PayPal lets customers pay for bookings and gift vouchers through PayPal's
own checkout, which suits overseas customers who don't want to enter a card on a South
African payment page. PiGi converts the amount to US dollars, sends the customer to
PayPal, and completes the payment when they return. Refunds can be sent back through
PayPal from PiGi.

You need a PayPal Business account. PayPal charges per transaction and for currency
conversion — see PayPal's fees page for your country. PiGi does not add PayPal's fee
to the customer's total.

## Before you start

- The **admin** role on your company in PiGi.
- A PayPal Business account for live payments, and access to the PayPal Developer
  Dashboard.
- An active ZAR → USD rate under Finance → Currency rates (see
  [Currencies and rates](../company-setup/currencies-and-rates.md)).

## Set up PayPal

1. Log in to the PayPal Developer Dashboard at developer.paypal.com.
2. Select **Apps & Credentials**. Make sure the dashboard is showing your sandbox
   apps, then open the **Default Application** under **REST API apps** or select
   **Create App**.
3. Copy the sandbox **client ID** and **client secret**.
4. Switch the dashboard to live, open or create a live app the same way, and copy its
   client ID and client secret. Live apps need a PayPal Business account.

## Connect it to PiGi

1. Open **Company → Settings → Finance → Payment Gateways**, click **Connect** on the
   PayPal card, then **Connect PayPal**. The credentials dialog opens.
2. On the **Sandbox** tab, enter the sandbox **Client ID** and **Client Secret**, and
   click **Save credentials**.
3. Click **Verify sandbox connection**. "Credentials verified successfully" means
   PayPal accepted the pair.
4. On the **Production** tab, enter the live pair, click **Save credentials**, then
   **Verify production connection**.
5. Turn on **Offer at booking checkout** in the PayPal sheet. For invoice "Pay Now"
   links, also tick PayPal under Invoicing → Settings → Online Payments.
6. To refund through PayPal, open **Refunds**, switch on **Enable Programmatic
   Refunds** and click **Save**.
7. When you're ready for real money, click **Production** on the Sandbox |
   Production switch in the PayPal sheet and confirm with **Go live**.

The rest of the screen is covered in
[Connect a payment gateway](../company-setup/payment-gateways.md).

## Test it

1. With PayPal on **Sandbox** and offered at checkout, make a booking on your public
   booking page and choose PayPal.
2. Log in on PayPal's sandbox page with a sandbox personal (buyer) account from your
   Developer Dashboard, approve the payment, and let PayPal return you to PiGi.
3. Confirm the booking shows the payment in rand and the sandbox business account
   received the US dollar amount.
4. Refund part of it from PiGi to prove refunds work.

## Troubleshooting

| Message | Fix |
|---|---|
| "Client ID and Client Secret are required" | Fill in both fields. |
| "Invalid credentials - authentication failed" | The pair is wrong, or a sandbox pair is on the Production tab (or the reverse). Copy it again from Apps & Credentials. |
| "No ZAR→USD exchange rate is set, so this payment can't be converted. Add one under Finance → Currency rates." | Add an active ZAR → USD rate under Finance → Currency rates. |
| "Failed to create PayPal order" | PayPal did not accept the payment. Check the PayPal account is in good standing and try again. |
| "Could not connect to payment gateway" / "Connection timed out - gateway may be unavailable" | PayPal could not be reached. Try again later. |

## Known limitations

- Customers are charged in US dollars, not rand. The amount depends on the rate you
  keep in Finance → Currency rates.
- The payment is only taken when the customer returns to PiGi from PayPal.
- Saved keys are never shown back to you. If you lose the secret, generate a new one
  in the PayPal Developer Dashboard.

## Sources

- [PayPal — get started with PayPal REST APIs](https://developer.paypal.com/api/rest/)
- [PayPal — Payments API v2 (refund captured payment)](https://developer.paypal.com/docs/api/payments/v2/)
