# Take online payments with PayFast

Connect your PayFast account so customers can pay for bookings by card or EFT on PayFast's payment page, with PayFast confirming each payment back to PiGi. You need a PayFast merchant account, its Merchant ID and Merchant Key, and a passphrase set in PayFast. Refunds are made in PayFast and recorded in PiGi by hand.

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

## Quick answers

**What does PiGi need from PayFast?**
Three things, all required: **Merchant ID**, **Merchant Key** and **Passphrase**. The
Merchant ID is a number.

**Where do I find my PayFast Merchant ID and Merchant Key?**
Sign in to your PayFast dashboard and go to **Settings → Developer Settings**. PayFast
also shows them under **Account → Personal Information**, at the top right of the page.

**Why does PiGi insist on a passphrase?**
PiGi signs every PayFast payment with your passphrase, so PayFast refuses the payment
if the passphrase is missing or different. Set a passphrase (PayFast calls it a "Salt
Passphrase") in your PayFast dashboard and type exactly the same one into PiGi.

**How do I test PayFast without real money?**
Register on the PayFast sandbox at sandbox.payfast.co.za. It gives you a sandbox
Merchant ID and Merchant Key, and you can set a Salt Passphrase there. Put those into
PiGi's **Sandbox** credentials.

**Do I need to set a notify (ITN) URL in PayFast?**
No. PiGi sends PayFast its notification address with every payment, and PayFast reports
the result there. You do not paste anything into PayFast.

**Can I refund a PayFast payment from PiGi?**
No. PiGi cannot send refunds through PayFast. Refund the customer in your PayFast
dashboard, then record the refund in PiGi. The gateway's **Refunds** row shows
"Manual" for this reason.

**A customer paid with PayFast but the booking is still unpaid. Why?**
PayFast confirms a payment by sending PiGi a notification. If the passphrase in PiGi
does not match the one in PayFast, or the amount PayFast reports differs from the
booking, PiGi ignores the notification. Check the passphrase first.

## What this does

Connecting PayFast lets customers pay for bookings and gift vouchers on PayFast's own
payment page, using the methods your PayFast account offers, such as card and EFT.
PayFast then notifies PiGi, which checks the notification with PayFast before marking
the booking paid.

You need a PayFast merchant account. PayFast charges per transaction — see PayFast's
pricing page. PiGi does not add PayFast's fee to the customer's total.

## Before you start

- The **admin** role on your company in PiGi.
- A PayFast merchant account for live payments, and a PayFast sandbox account for
  testing.

## Set up PayFast

1. Sign in to the PayFast sandbox (sandbox.payfast.co.za) with your email address and
   note the sandbox **Merchant ID** and **Merchant Key** it gives you.
2. In the sandbox **Settings**, create a **Salt Passphrase** and note it.
3. Sign in to your live PayFast dashboard and open **Settings → Developer Settings**.
   Copy your **Merchant ID** and **Merchant Key**.
4. Set a passphrase on the live account in the dashboard's settings. Copy it exactly —
   spaces and capitals matter.

## Connect it to PiGi

1. Open **Company → Settings → Finance → Payment Gateways**, click **Connect** on the
   PayFast card, then **Connect PayFast**. The credentials dialog opens.
2. On the **Sandbox** tab, enter the sandbox **Merchant ID**, **Merchant Key** and
   **Passphrase**, and click **Save credentials**.
3. Click **Verify sandbox connection**. "Credentials verified successfully" means
   PayFast accepted the ID and passphrase.
4. On the **Production** tab, enter your live details, click **Save credentials**,
   then **Verify production connection**.
5. Turn on **Offer at booking checkout** in the PayFast sheet. For invoice "Pay Now"
   links, also tick PayFast under Invoicing → Settings → Online Payments.
6. When you're ready for real money, click **Production** on the Sandbox |
   Production switch in the PayFast 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 PayFast on **Sandbox** and offered at checkout, make a booking on your public
   booking page and choose PayFast.
2. Complete the payment on the PayFast sandbox page.
3. Wait a few seconds after returning, then refresh the booking in PiGi — it is
   marked paid once PayFast's notification has been checked.
4. After going live, make one small real payment and confirm it shows both in PayFast
   and on the booking.

## Troubleshooting

| Message | Fix |
|---|---|
| "Merchant ID, Merchant Key, and Passphrase are required" | Fill in all three fields. |
| "Merchant ID must be numeric" | You pasted the Merchant Key into Merchant ID. The ID is digits only. |
| "PayFast refused these keys — check the Merchant ID and passphrase." | The ID and passphrase don't match the account, or you used live details on the Sandbox tab (or the reverse). |
| "Could not connect to payment gateway" / "Connection timed out - gateway may be unavailable" | PayFast could not be reached. Try again later. |
| PayFast shows a signature error when the customer arrives | The passphrase in PiGi differs from the one in PayFast. Re-enter it on both sides. |
| Booking stays unpaid after a successful PayFast payment | Check the passphrase, then contact PiGi support with the booking reference. |

## Known limitations

- Refunds cannot be sent from PiGi; refund in PayFast and record it in PiGi.
- The link that takes a customer to PayFast is valid for one hour. After that they
  need to start the payment again.
- A booking is only marked paid when PayFast's notification arrives and checks out.
- Saved keys are never shown back to you. If you lose the passphrase, set a new one in
  PayFast and in PiGi.

## Sources

- [Payfast — navigate your Payfast dashboard](https://support.payfast.help/portal/en/kb/articles/navigate-your-payfast-dashboard-20-9-2022)
- [Payfast — how do I make test payments in sandbox mode?](https://support.payfast.help/portal/en/kb/articles/how-do-i-make-test-payments-in-sandbox-mode-20-9-2022)
- [Payfast — what causes the ITN security check errors?](https://support.payfast.help/portal/en/kb/articles/what-causes-the-itn-security-check-errors-20-9-2022)
