PHPackages                             rainwaves/payfast-payment - 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. rainwaves/payfast-payment

ActiveLibrary

rainwaves/payfast-payment
=========================

This is a PHP package for integrating with the PayFast.co.za payment gateway. It provides a convenient way to handle one-time payments and recurring billing in your PHP applications, with support for both vanilla PHP and Laravel.

v1.6.0(3mo ago)0962MITPHPPHP ^7.4|^8.0|^8.1|^8.2

Since Jul 13Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/Magnificent-Big-J/payfast-payment)[ Packagist](https://packagist.org/packages/rainwaves/payfast-payment)[ RSS](/packages/rainwaves-payfast-payment/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (7)Dependencies (2)Versions (9)Used By (0)

Payfast Payment Package
=======================

[](#payfast-payment-package)

This is a PHP package for integrating with the PayFast payment gateway. It provides a convenient way to handle one-time payments and recurring billing in your PHP applications, with support for both vanilla PHP and Laravel.

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

[](#installation)

You can install the package via Composer. Run the following command in your project directory:

```
composer require rainwaves/payfast-payment
```

Configuration
-------------

[](#configuration)

After installing the package, you need to configure it with your PayFast credentials. In Laravel, you'll need to publish the config file and set the credentials in your .env file:

- merchant\_id=XXXXXXXX
- merchant\_key=XXXXXXXXXX
- env=local|production
- return\_url=XXXXXXXXXXXX
- cancel\_url=XXXXXXXXXXXX
- notify\_url=XXXXXXXXXXXX
- pass\_phrase=XXXXXXXXXXXX

Compatibility
-------------

[](#compatibility)

- PHP: 7.4+ and 8.x (including 8.3 and 8.4).
- Laravel: 8.x through 12.x.

Laravel 10+ requires PHP 8.1+, and Laravel 11+ requires PHP 8.2+. Align your project PHP version accordingly.

Usage
-----

[](#usage)

### Vanilla PHP

[](#vanilla-php)

```
require 'vendor/autoload.php';

$config = array('merchant_id' => 10000100,
    'merchant_key'=> '46f0cd694581a',
    'env'=> 'local',
    'return_url'=> 'https://www.example.com/success',
    'cancel_url'=> 'https://www.example.com/cancel',
    'notify_url'=> 'https://www.example.com/notify',
    'pass_phrase' => 'jt7NOE43FZPn',
);
$input = array(
    'amount' => 100.00,
    'item_name' => 'Test Product',
    'name_first' => 'First Name',
    'name_last'  => 'Last Name',
    'email_address'=> 'test@test.com',
    'm_payment_id' => '1234',
    'email_confirmation' => true,
    'custom_str1' => 'example',
);

$payFast = new PayFast($config);
echo $payFast->makePaymentWithAForm($input)->createForm();
```

A form with hidden inputs will be returned.

### Laravel

[](#laravel)

Assuming you have the necessary routes and views set up, here's an example of how to use the package in Laravel:

```
use Illuminate\Http\Request;
use rainwaves\PayfastPayment\PayFast;

class PaymentController extends Controller
{
    public function makePayment(Request $request)
    {
        $config = [
            'merchant_id' => config('payfast.merchant_id'),
            'merchant_key' => config('payfast.merchant_key'),
            'env' => config('payfast.env'),
            'return_url' => config('payfast.return_url'),
            'cancel_url' => config('payfast.cancel_url'),
            'notify_url' => config('payfast.notify_url'),
            'pass_phrase' => config('payfast.pass_phrase'),
        ];

        $input = [
            'amount' => 100.00,
            'item_name' => 'Test Product',
            'name_first' => $request->input('name_first'),
            'name_last' => $request->input('name_last'),
            'email_address' => $request->input('email'),
            'm_payment_id' => '1234',
            'email_confirmation' => true,
            'custom_str1' => 'example',
        ];

        $payFast = new PayFast($config);
        return $payFast->makePaymentWithAForm($input)->createForm();
    }
}
```

### Subscriptions

[](#subscriptions)

```
use rainwaves\PayfastPayment\PayFastSubscription;
use rainwaves\PayfastPayment\Model\Frequency;

$payFast = new PayFastSubscription($config);
$input = [
    'amount' => 100.00,
    'item_name' => 'Gold Plan',
    'billing_date' => '2026-03-01',
    'recurring_amount' => 100.00,
    'frequency' => Frequency::MONTHLY,
    'cycles' => 0, // 0 = indefinite
    'subscription_notify_email' => true,
    'subscription_notify_webhook' => true,
    'subscription_notify_buyer' => true,
];

echo $payFast->createSubscriptionWithAForm($input)->createForm();
```

### Optional Fields

[](#optional-fields)

- `custom_int1..5`, `custom_str1..5`
- `payment_method`
- `email_confirmation`, `confirmation_address`

### ITN (Instant Transaction Notification) Validation

[](#itn-instant-transaction-notification-validation)

PayFast requires verification of ITN messages (signature, source, and data). You can validate signatures and optionally call the PayFast validation endpoint:

```
use rainwaves\PayfastPayment\Itn\PayFastItnValidator;

$payload = $_POST; // ITN payload
$rawBody = file_get_contents('php://input'); // raw ITN body
$validator = new PayFastItnValidator($payload, config('payfast.pass_phrase'), $rawBody);

if (!$validator->validateSignature()) {
    // invalid signature
}

if (!$validator->validateAmount('100.00')) {
    // amount mismatch
}

if (!$validator->validateMerchantId(config('payfast.merchant_id'))) {
    // merchant mismatch
}

// Optional: validate with PayFast endpoint (see PayFast docs for URL)
if (!$validator->validateWithPayFastEndpoint($validateUrl)) {
    // validation failed
}
```

Notes
-----

[](#notes)

- PayFast recommends enabling a passphrase on your account for secure signature validation, and recurring billing requires a passphrase to avoid signature errors.
- Ensure you verify ITN requests per PayFast’s integration requirements (signature, source IP, and amount checks).

Testing
-------

[](#testing)

To run the PHPUnit test cases for the package, use the following command:

vendor/bin/phpunit

License
-------

[](#license)

This package is open-source software licensed under the MIT license.

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance82

Actively maintained with recent releases

Popularity19

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 96.4% 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 ~157 days

Recently: every ~234 days

Total

7

Last Release

94d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d883daa69ded754005d02d8e31aec80f0ef4c73cfd20b9d3f6daad32dce0d0cb?d=identicon)[Magnificent-Big-J](/maintainers/Magnificent-Big-J)

---

Top Contributors

[![Magnificent-Big-J](https://avatars.githubusercontent.com/u/30896750?v=4)](https://github.com/Magnificent-Big-J "Magnificent-Big-J (53 commits)")[![mnisij](https://avatars.githubusercontent.com/u/14214514?v=4)](https://github.com/mnisij "mnisij (2 commits)")

### Embed Badge

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

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

###  Alternatives

[league/openapi-psr7-validator

Validate PSR-7 messages against OpenAPI (3.0.2) specifications expressed in YAML or JSON

55715.9M69](/packages/league-openapi-psr7-validator)[davidepastore/slim-validation

A slim middleware for validation based on Respect/Validation

171223.7k3](/packages/davidepastore-slim-validation)[hkarlstrom/openapi-validation-middleware

PSR-7 and PSR-15 OpenAPI Validation Middleware

95198.8k1](/packages/hkarlstrom-openapi-validation-middleware)[awurth/slim-validation

A wrapper around the respect/validation PHP validation library for easier error handling and display

65378.4k9](/packages/awurth-slim-validation)[macfja/redisearch

PHP Client for RediSearch

67154.9k1](/packages/macfja-redisearch)[lanlin/nylas-php

Nylas PHP SDK (api version 2.7)

28258.7k](/packages/lanlin-nylas-php)

PHPackages © 2026

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