PHPackages                             payfast/payfast-common - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Payment Processing](/categories/payments)
4. /
5. payfast/payfast-common

ActiveLibrary[Payment Processing](/categories/payments)

payfast/payfast-common
======================

Payfast common class for modules.

v1.4.1(9mo ago)14.8k↑396.9%11GPL-3.0PHPPHP ^8.1

Since Apr 12Pushed 9mo ago2 watchersCompare

[ Source](https://github.com/PayFast/payfast-common)[ Packagist](https://packagist.org/packages/payfast/payfast-common)[ Docs](https://github.com/PayFast/payfast-common)[ RSS](/packages/payfast-payfast-common/feed)WikiDiscussions main Synced today

READMEChangelog (10)Dependencies (1)Versions (12)Used By (1)

payfast-common
==============

[](#payfast-common)

Payfast common class for modules
--------------------------------

[](#payfast-common-class-for-modules)

This is the Payfast common class for modules.

Installation
------------

[](#installation)

You can install this module using composer:

```
composer require payfast/payfast-common
```

Aggregator
----------

[](#aggregator)

### Module parameters for pfValidData()

[](#module-parameters-for-pfvaliddata)

Declare the relevant $moduleInfo values when using the **pfValidData()** method, for example:

```
$moduleInfo = [
    "pfSoftwareName"       => 'OpenCart',
    "pfSoftwareVer"        => '4.0.2.0',
    "pfSoftwareModuleName" => 'PF_OpenCart',
    "pfModuleVer"          => '2.3.1',
];

$pfValid = $payfastCommon->pfValidData($moduleInfo, $pfHost, $pfParamString);

```

### Debug Mode

[](#debug-mode)

Configure debug mode by passing true|false when instantiating the **Payfast\\PayfastCommon\\Aggregator\\Request\\PaymentRequest** class.

```
$aggregatorPaymentRequest = new Payfast\PayfastCommon\Aggregator\Request\PaymentRequest(true);

```

### Breaking Changes since v1.2.0

[](#breaking-changes-since-v120)

#### Namespace Changes: **`Payfast` → `Aggregator`**

[](#namespace-changes-payfast--aggregator)

The namespaces for several core classes have been updated to improve consistency and better align with the library's purpose. This requires updating your imports to reflect the new structure.

#### Class Renames

[](#class-renames)

To enhance clarity and maintain consistency, some classes have been renamed. Make sure to update your code to reference the new class names.

#### Example of Correct and Incorrect Usage:

[](#example-of-correct-and-incorrect-usage)

#### Correct

[](#correct)

```
use Payfast\PayfastCommon\Aggregator\Request\PaymentRequest;

$paymentRequest = new PaymentRequest($testMode);
```

#### Incorrect

[](#incorrect)

```
use Payfast\PayfastCommon\PayfastCommon;

$payfastCommon = new PayfastCommon($testMode);
```

### Breaking Changes since v1.1.0

[](#breaking-changes-since-v110)

We have migrated from static to instance methods for the Aggregator PaymentRequest class.

For example, prior to v1.1.0 we used:

```
// Debug mode
define('PF_DEBUG', true);

// Module parameters for pfValidData
define('PF_SOFTWARE_NAME', 'GravityForms');
define('PF_SOFTWARE_VER', '2.8.7');
define('PF_MODULE_NAME', 'PayFast-GravityForms');
define('PF_MODULE_VER', '1.5.4');

// Calling methods on Payfast\PayfastCommon\Aggregator\Request\PaymentRequest
$pfData = PaymentRequest::pfGetData();
PaymentRequest::pflog('Verify data received');

```

But this has now become:

```
// Debug mode
$aggregatorPaymentRequest = new PaymentRequest(true);

// Module parameters for pfValidData
$moduleInfo = [
    "pfSoftwareName"       => 'GravityForms',
    "pfSoftwareVer"        => '2.8.7',
    "pfSoftwareModuleName" => 'PayFast-GravityForms',
    "pfModuleVer"          => '1.5.4',
];
$pfValid = $aggregatorPaymentRequest->pfValidData($moduleInfo, $pfHost, $pfParamString);

// Calling methods on Payfast\PayfastCommon\Aggregator\Request\PaymentRequest
$pfData = $aggregatorPaymentRequest->pfGetData();
$aggregatorPaymentRequest->pflog('Verify data received');

```

Gateway
-------

[](#gateway)

### Usage examples

[](#usage-examples)

#### Payment Initiate

[](#payment-initiate)

```
try {
    $paymentRequest   = new PaymentRequest($merchantId, $encryptionKey);
    $response = $paymentRequest->initiate($data);
} catch (Exceptione $e) {
    echo 'Error initiating payment: ' . $e->getMessage();
}
```

#### Redirect to Gateway

[](#redirect-to-gateway)

```
echo $paymentRequest->getRedirectHTML($payRequestId, $checksum);
```

#### Query Transaction

[](#query-transaction)

```
try {
    $paymentRequest   = new PaymentRequest($merchantId, $encryptionKey);
    $response = $paymentRequest->query($payRequestId, $reference);
} catch (Exceptione $e) {
    echo 'Error querying transaction: ' . $e->getMessage();
}
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance58

Moderate activity, may be stable

Popularity26

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~90 days

Recently: every ~75 days

Total

11

Last Release

277d ago

PHP version history (2 changes)v1.0.0PHP ^8.0

v1.2.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/e43f9b8896ff41b8802027690ea1151e502afcb8ce9eab81a451f8e18315080f?d=identicon)[charlretief](/maintainers/charlretief)

![](https://www.gravatar.com/avatar/10d0cd11e224ce0a94fd91271321f6a8c4fdc9223cbbe8659977861bad26d922?d=identicon)[jc1arke](/maintainers/jc1arke)

---

Top Contributors

[![bruce-atkinson](https://avatars.githubusercontent.com/u/13369065?v=4)](https://github.com/bruce-atkinson "bruce-atkinson (35 commits)")

### Embed Badge

![Health badge](/badges/payfast-payfast-common/health.svg)

```
[![Health](https://phpackages.com/badges/payfast-payfast-common/health.svg)](https://phpackages.com/packages/payfast-payfast-common)
```

###  Alternatives

[aws/aws-sdk-php

AWS SDK for PHP - Use Amazon Web Services in your PHP project

6.3k543.5M2.6k](/packages/aws-aws-sdk-php)[neuron-core/neuron-ai

The PHP Agentic Framework.

2.0k656.1k38](/packages/neuron-core-neuron-ai)[tencentcloud/tencentcloud-sdk-php

TencentCloudApi php sdk

3741.3M46](/packages/tencentcloud-tencentcloud-sdk-php)[chargebee/chargebee-php

ChargeBee API client implementation for PHP

758.5M9](/packages/chargebee-chargebee-php)[tempest/framework

The PHP framework that gets out of your way.

2.2k34.4k15](/packages/tempest-framework)[imdhemy/google-play-billing

Google Play Billing

491.5M5](/packages/imdhemy-google-play-billing)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
