PayFast is our recommended payments processing service for South Africans and South African websites. Their payment gateway offers a secure and instant transfer of money between online buyers and sellers. Merchants can accept funds from local and international customers from anywhere in the world in ZAR.

Fees are charged per-transaction according to this fee schedule and there are no setup or monthly fees.

Installation | Setup | Custom Trial Periods | Troubleshooting “Pending” Orders | Orders in “Token” Status | Action and Filter Hooks

Video Demo

Installation

  1. Make sure you have the Paid Memberships Pro plugin installed and activated.
  2. Navigate to Plugins > Add New in the WordPress admin.
  3. Search for “Payfast Payment Gateway for PMPro”.
    • Or, install this plugin manually, download the .zip file above then upload the compressed directory via the Plugins > Add New > Upload Plugin screen in the WordPress admin.
  4. Activate the plugin through the ‘Plugins’ menu in WordPress.

Continue following the setup instructions below.

Setup

  1. Register and validate your account with PayFast.
  2. Log in to your PayFast account and select ‘Settings’ to retrieve your merchant details.
  3. Log in to your WordPress dashboard and navigate to Memberships > Payment Settings.
  4. Set your “Payment Gateway” to “PayFast”. Fill out your merchant details and Passphrase*
  5. Set your currency to “South African Rand”.
  6. Save your settings.
* Please note that a “Security Passphrase” is required in order to accept recurring payments. You are able to set this under your account settings inside PayFast.

Enable “PayFast Debug Mode”

To enable the debugging mode, navigate to Payment Settings > PayFast. Then, change the setting for “PayFast Debug Mode” then save settings. With this setting enabled, you can test payments, cancellations, and recurring payments. The log file will be created inside the pmpro-payfast/logs folder.

Custom Trial Periods

The Payfast Gateway API does not support custom trials. You can set the initial payment to $0 and adjust your recurring amount to offer a trial for members. If you need to set a variable length period between the initial payment and the start of the recurring subsection, please use the Subscription Delays Add On.

Troubleshooting PayFast Orders Stuck in Pending Status

The most common reason orders stay in ‘pending’ status with PayFast is due to Instant Transaction Notifications (ITN) not sending or processing on the site. Similar to the PayPal IPN system, a working Payfast ITN is required to confirm the charge is valid and was successful with the gateway.

ITN is required for all types of payments, including the initial payment and all recurring payments. Some possible reasons your ITN is failing are listed below.

ITN URL is hardcoded/set incorrectly.

With PMPro, you do not need to set the Notify URL in Payfast. Leave your ITN Status set to “disabled”. The API will handle setting ITN and status this automatically.

If the ITN URL set inside PayFast settings is hardcoded or it is set to an incorrect URL (or another site’s URL), your ITN can fail. To fix this, disable the ITN URL in Payfast settings.

Screenshot of the Notification Settings > ITN section of Payfast Gateway Account

Server Side Blocking IP Addresses

Your web host may block incoming IP requests from frequent addresses. We do not see this as a common issue, but it is possible and important to note here for debugging.

Listed below are the IP address ranges that PayFast servers use (including their Sandbox server).

  • 197.97.145.144 / 28 (197.97.145.145 – 197.97.145.158)
  • 41.74.179.192 / 27 (41.74.179.193 – 41.74.179.222)
  • 144.126.193.139 (Sandbox IP)

Reach out to your hosting provider to ensure there is no block on these IPs from the server side

Orders in Token Status

Orders in the “token” status mean that the customer reached the PayFast checkout page but did not complete the order. This is similar to how PayPal Express handles payments. This guide has more detailed information about the various order statuses in Paid Memberships Pro.

Action and Filter Hooks

apply_filters( 'pmpro_payfast_hide_update_billing_button', true );

apply_filters( 'pmpro_payfast_data', $data, $order );

apply_filters( 'pmpro_payfast_itnhandler_level', $morder->membership_level, $morder->user_id );

do_action( 'pmpro_before_send_to_payfast', $user_id, $morder );

This is a Free Add On.

Create a free account or log in to gain access to downloads and documentation.