How do I integrate PayFast with Drupal Commerce?
You’ll need a working installation of Drupal Commerce before you can integrate with PayFast. Kindly see their website for more information.
Integration steps for Drupal-7 Commerce:
Requirements
- Drupal 7 (or commerce_kickstart)
- Commerce 7
Installation
- Download the module from https://github.com/PayFast/mod-drupalcommerce-7/archive/master.zip and extract the contents into a new folder.
- Move or copy this new folder to your “sites/all/modules” directory.
- Log in as a privileged user on your Drupal7 site.
- Navigate to modules via the admin menu and enable PayFast by checking the checkbox and scrolling down to the bottom and clicking Save configuration.
- Navigate to Configure Store via Store on the admin menu, select Payment methods and:
- Click PayFast under the Enabled payment method rules.
- Under Actions in the Elements block, click Enable payment method PayFast.
- The sandbox credentials will be filled in automatically.
- Click Save to make test transactions with the sandbox.
- To make real transactions select live and replace the sandbox credentials with your PayFast Merchant ID and Key.
Subscriptions
Log in to your PayFast account and enable Subscription Billing by navigating to Settings > integration.
- Log in to the admin dashboard of your Drupal Commerce site and click Store.
- Navigate to Product Types and add a subscription type.
- Under Manage Fields of the subscription product type, add the following fields with respective ‘Label’, ‘Machine Name’, ‘Field Type’ and ‘Widget’ (see screenshot).
- cycles, field_cycles, Integer, Text Field
- frequency, field_frequency, Integer, Text Field
- subscription_type, field_subscription_type, Integer, Text Field
- recurring_amount, field_recurring_amount, Price, Price Textfield
- Manage the display as required.
- Navigate back to Product and add a product of subscription type, and set the subscription fields as follows:
- Set cycles to the number of payments required (set to 0 for infinite)
- Set frequency to 3 for monthly, 4 for quarterly, 5 for biannual or 6 for annual payments
- Set subscription_type to 1
- Set recurring amount as required
- Click Save.
Please note: It is not possible to test subscriptions in sandbox with this integration.
Once the subscription has been initiated, each subsequent payments for that order will appear under the Payment section of the order (as per the screenshot), the total amount will show the total amount paid to date for the order and the balance will show the difference between the initial amount and each subscription payment.
Integration steps for Drupal-8 Commerce:
- Download the PayFast module.
- Unzip and copy the PayFast folder to the ../modules/contrib/commerce/modules directory.
- Log in to the admin dashboard and install Commerce PayFast on the Extend page.
- Navigate to Commerce > Configuration > Payments and click new payment gateway.
- Select PayFast and configure as required.
- Click Save.
Subscriptions
- Log in to your PayFast account and enable Subscription Billing by navigating to Settings > Integration.
- Log in to the admin dashboard of your Drupal Commerce site and click Commerce.
- Navigate to Configuration > Product Types > Add product type and add a subscription type.
- Edit the added subscription type under Manage Fields of the subscription product type. Add the following fields with respective Label, Machine Name, Field Type and Widget.
- cycles, field_cycles, Number(Integer),
- frequency, field_frequency, Number(Integer),
- subscription_type, field_subscription_type, Number(Integer),
- recurring_amount, field_recurring_amount, Number(decimal),
- Manage the display as required.
- Navigate to Commerce > Products and add a product of subscription type. Set the subscription fields as follows:
- Set cycles to the number of payments required (set to 0 for infinite)
- Set frequency to 3 for monthly, 4 for quarterly, 5 for biannual or 6 for annual payments
- Set subscription_type to 1
- Set recurring amount as required
- Click Save.
Please note: It is not possible to test subscriptions in sandbox with this integration.
Once the subscription has been initiated, each subsequent payments for that order will appear under the Payment section of the order, the Total amount will show the total amount paid to date for the order and the Balance will show the difference between the initial amount and each subscription payment.
Related Articles
How do I integrate PayFast with Mal's E-commerce?
This module was developed by Mal's E-commerce, so please visit their website for integration support. You will need to be registered on PayFast to accept payments and get your Merchant ID.
How do I integrate PayFast with Loaded Commerce?
To install the PayFast payment module, do the following: Download the payment module from Github. Unzip the module to a temporary location on your computer. Copy the addons folder in the archive to your base Loaded Commerce folder. This should not ...
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 ...
How do I integrate PayFast with WP eCommerce?
In order to use PayFast with WP e-Commerce, you will need to install the PayFast payment module for WP e-Commerce which is provided by PayFast. Installation requirements A working WordPress installation with the WP e-Commerce plugin installed ...
How do I integrate PayFast with Site.pro?
This module was developed by Site.pro, so please visit their website for integration support. You will need to be registered on PayFast to accept payments and get your Merchant ID. You will also need a Premium account with Site.pro to be able to use ...