How do I integrate PayFast with OpenCart?

How do I integrate PayFast with OpenCart?

Please note: The plugin files for OpenCart version 3 and OpenCart version 2 are not compatible. You will need to install the exact plugin compatible with your OpenCart installation.

Installation requirements

  • A working OpenCart installation
  • The default currency on OpenCart is South African ZAR
  • A geo-zone for South Africa is set on OpenCart Localisation settings

Installation 

To install the PayFast payment module, do the following:

  1. Download the v3+ module. (For older versions, see instructions in the section for 'Older Versions & Upgrading'.)
  2. Unzip the module to a temporary location on your computer.
  3. Copy the admin and catalog folders into the base OpenCart folder.
    • This should NOT overwrite any existing files or folders and merely supplement them with the PayFast files.
    • This is, however, dependent on the FTP program you use.
    • If you are concerned about this, rather copy the individual files across as per instructions below.
  4. Log in to the admin section of your OpenCart installation.
  5. Navigate to Extensions > Payments.
  6. Scroll down to the PayFast.co.za payment method and click Install to install the module.
  7. Once the module is installed, click Edit.
  8. The PayFast options will then be shown, select the payment status for completed, failed and pending'payments, select the sandbox mode, enable the payment module and click Save.
  9. The module is now ready to be tested with the PayFast Sandbox.
  10. When you are ready to go live, input your PayFast Merchant ID, Key and passphrase (if it is set on your account), and set sandbox to no.
  11. Click Save.

Copying the individual files across

If you are concerned that copying the entire folder from the downloaded module may overwrite files in your installation, rather copy the files from the extracted module individually into your installation.

Be sure to copy the files from the downloaded module to their corresponding locations within your installation:

The list of files needed in your online installation is as follows:

OpenCart 3
admin/controller/extension/payment/payfast.php 
admin/language/en-gb/extension/payment/payfast.php 
admin/view/image/payment/payfast.png 
admin/view/image/payment/payfastlogo.gif 
admin/view/template/extension/payment/payfast.twig 
catalog/controller/extension/payment/payfast.php
catalog/controller/extension/payment/payfast_common.inc
catalog/language/en-gb/extension/payment/payfast.php 
catalog/model/extension/payment/payfast.php 
catalog/view/theme/default/image/payfast.png 
catalog/view/theme/default/image/payfastlogo.gif 
catalog/view/theme/default/template/extension/payment/payfast.twig

Testing that it is working correctly

If you followed the installation instructions above, the module is in 'test' mode and you can test it by purchasing from your site as a buyer normally would. You will be redirected to PayFast for payment and can log in with the user account detailed above and make payment using the balance in their wallet.

You will not be able to directly 'test' a credit card, Instant EFT or any other payment method in the sandbox, but you don’t really need to. The inputs to and outputs from PayFast are exactly the same, no matter which payment method is used, so using the wallet will give you exactly the same results as if you had used another payment method.

Going live

In order to make the module “live”, do the following:

  1. Log in to the admin section of your OpenCart system.
  2. Navigate Extensions > Payments.
  3. Under PayFast.co.za, click Edit.
  4. In the PayFast Settings block, use the following settings:    
    • Set Sandbox Mode = “No”
    • Merchant ID = <Login to PayFast -> Integration Page>
    • Merchant Key = <Login to PayFast -> Integration Page>
  5. Click Save.

    • Related Articles

    • In OpenCart, why isn't PayFast listed in the checkout?

      If PayFast isn't listed in the checkout, do the following: Ensure that you are using the latest version of our plugin for the correlating version of OpenCart. Ensure that you have added a South African geo-zone (at System > Localisation > Geo Zones). ...
    • How do I integrate PayFast with MijoShop?

      To install the PayFast payment module, do the following: Download the payment module from GitHub (v2; v3). Unzip the module to a temporary location on your computer. Copy the folders in the archive to your base Joomla folder. This should NOT ...
    • What is the payment flow in OpenCart?

      PayFast works on browser redirection and will redirect the user to PayFast for payment after they click the Confirm Order button on the checkout page. At this stage, the order has NOT been created in OpenCart, but the shopping cart details will be ...
    • How do I set up recurring billing on OpenCart?

      To set up recurring billing on OpenCart, do the following: The instructions for integration must be completed first, before setting up recurring billing. Log in to your PayFast Dashboard and navigate to Settings > Integration. Click Enable or Edit ...
    • How do I integrate PayFast with UberCart?

      To integrate PayFast with UberCart, do the following: Download the PayFast module and extract the uc_payfast folder from the zip folder. Move or copy the folder called ”uc_payfast” into your /modules/ubercart/payment directory. Log in to the admin ...