How do I integrate PayFast with Drupal Commerce?

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 

  1. Download the module from https://github.com/PayFast/mod-drupalcommerce-7/archive/master.zip and extract the contents into a new folder.
  2. Move or copy this new folder to your “sites/all/modules” directory.
  3. Log in as a privileged user on your Drupal7 site.
  4. Navigate to modules via the admin menu and enable PayFast by checking the checkbox and scrolling down to the bottom and clicking Save configuration.
  5. Navigate to Configure Store via Store on the admin menu, select Payment methods and:
    1. Click PayFast under the Enabled payment method rules.
    2. Under Actions in the Elements block, click Enable payment method PayFast.
    3. The sandbox credentials will be filled in automatically.
    4. Click Save to make test transactions with the sandbox.
    5. To make real transactions select live and replace the sandbox credentials with your PayFast Merchant ID and Key.

Subscriptions  

  1. Log in to your PayFast account and enable Subscription Billing by navigating to Settings > integration.
  2. Log in to the admin dashboard of your Drupal Commerce site and click Store.
  3. Navigate to Product Types and add a subscription type.
  4. 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
  5. Manage the display as required.
  6. 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

  7. 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:

  1. Download the PayFast module.
  2. Unzip and copy the PayFast folder to the ../modules/contrib/commerce/modules directory.
  3. Log in to the admin dashboard and install Commerce PayFast on the Extend page.
  4. Navigate to Commerce > Configuration > Payments and click new payment gateway.
  5. Select PayFast and configure as required.
  6. Click Save.

Subscriptions

  1. Log in to your PayFast account and enable Subscription Billing by navigating to Settings > Integration.
  2. Log in to the admin dashboard of your Drupal Commerce site and click Commerce.
  3. Navigate to Configuration > Product Types > Add product type and add a subscription type.
  4. 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),

  1. Manage the display as required.
  2. 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
  3. 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 ...