Start a conversation

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 on '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 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 '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 ‘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 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'.

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 into 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 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  ‘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’ (see screenshot).
    • 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'.

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.


Choose files or drag and drop files
Helpful?
Yes
No