Drupal Commerce

Drupal Commerce is an open source eCommerce framework. Use it to build flexible eCommerce websites and applications based on Drupal. Safe and secure payments by PayFast.

Drupal Commerce


You’ll need a working installation of Drupal Commerce before you can integrate with PayFast. Kindly see their website for more information.

See PayFast integration steps for Drupal-7 Commerce


  1. Drupal 7 (or commerce_kickstart)
  2. Commerce 7


  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 the module
  5. Navigate to “Payment methods” via the admin menu and
    1. click on “PayFast” under the “Enabled payment method rules”,
    2. then, under “Actions” in the “Elements” block, click on “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


  1. Log into your PayFast account and enable subscription billing on the settings>integration page
  2. Log into the admin dashboard of your Drupal Commerce site and click on ‘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 ‘Products’ 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 freqeuncy 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
  8. 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.

See PayFast 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 into the admin dashboard and install Commerce PayFast on the ‘Extend’ page
  4. Navigate to Commerce>Configuration>Payments and click on ‘new payment gateway’
  5. Select PayFast and configure as required
  6. Click ‘Save’