PHPackages                             payfastsdk/payfast-php-sdk - 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. [API Development](/categories/api)
4. /
5. payfastsdk/payfast-php-sdk

ActiveLibrary[API Development](/categories/api)

payfastsdk/payfast-php-sdk
==========================

PayFast PHP Library

1.0.0(5y ago)025MITPHPPHP &gt;=7.2.5

Since Nov 20Pushed 5y ago1 watchersCompare

[ Source](https://github.com/klair/payfast-php-sdk)[ Packagist](https://packagist.org/packages/payfastsdk/payfast-php-sdk)[ RSS](/packages/payfastsdk-payfast-php-sdk/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

PayFast PHP SDK
===============

[](#payfast-php-sdk)

The PayFast PHP SDK provides an easy to use library for integrating PayFast payments into your project. This includes Custom Integration, Onsite Integration and all APIs.

Requirements
------------

[](#requirements)

PHP 7.2.5 and later.

Documentation
-------------

[](#documentation)

See the [Developer Docs](https://developers.payfast.co.za/docs)

Composer
--------

[](#composer)

You can install the library via [Composer](http://getcomposer.org/). Run the following command:

```
composer require payfastsdk/payfast-php-sdk
```

To use the library, use Composer's [autoload](https://getcomposer.org/doc/01-basic-usage.md#autoloading):

```
require_once('vendor/autoload.php');
```

Getting Started
---------------

[](#getting-started)

### Custom Integration

[](#custom-integration)

Build a checkout form and receive payments securely from the PayFast payment platform.

```
try {
    $payfast = new PayFastPayment(
        [
            'merchantId' => '10000100',
            'merchantKey' => '46f0cd694581a',
            'passPhrase' => '',
            'testMode' => true
        ]
    );

    $data = [
        'amount' => '100.00',
        'item_name' => 'Order#123'
    ];

    echo $payfast->custom->createFormFields($data, ['value' => 'PAY NOW', 'class' => 'btn']);
} catch(Exception $e) {
    echo 'There was an exception: '.$e->getMessage();
}
```

### Onsite Payments

[](#onsite-payments)

Integrate PayFast’s secure payment engine directly into your checkout page.

```
try {
    $payfast = new PayFastPayment(
        [
            'merchantId' => '10000100',
            'merchantKey' => '46f0cd694581a',
            'passPhrase' => '',
            'testMode' => false
        ]
    );

    $data = [
        'amount' => '100.00',
        'item_name' => 'Order#123'
    ];

    // Generate payment identifier
    $identifier = $payfast->onsite->generatePaymentIdentifier($data);

    if($identifier!== null){
        echo 'window.payfast_do_onsite_payment({"uuid":"'.$identifier.'"});';
    }
} catch(Exception $e) {
    echo 'There was an exception: '.$e->getMessage();
}
```

### API

[](#api)

#### Recurring Billing

[](#recurring-billing)

The Subscription Payments API gives Merchants the ability to interact with subscriptions on their accounts.

```
try {
    $api = new PayFastApi(
        [
            'merchantId' => '10018867',
            'passPhrase' => '2uU_k5q_vRS_',
            'testMode' => true
        ]
    );

    $fetchArray = $api->subscriptions->fetch('2afa4575-5628-051a-d0ed-4e071b56a7b0');

    $pauseArray = $api->subscriptions->pause('2afa4575-5628-051a-d0ed-4e071b56a7b0', ['cycles' => 1]);

    $unpauseArray = $api->subscriptions->unpause('2afa4575-5628-051a-d0ed-4e071b56a7b0');

    $cancelArray = $api->subscriptions->cancel('2afa4575-5628-051a-d0ed-4e071b56a7b0');

    $updateArray = $api->subscriptions->update('2afa4575-5628-051a-d0ed-4e071b56a7b0', ['cycles' => 1]);

    $adhocArray = $api->subscriptions->adhoc('290ac9a6-25f1-cce4-5801-67a644068818', ['amount' => 500, 'item_name' => 'Test adhoc']);

} catch(Exception $e) {
    echo 'There was an exception: '.$e->getMessage();
}
```

#### Transaction History

[](#transaction-history)

The transaction history API gives Merchants the ability to interact with their PayFast account.

```
try {
    $api = new PayFastApi(
        [
            'merchantId' => '10018867',
            'passPhrase' => '2uU_k5q_vRS_',
            'testMode' => true
        ]
    );

    $rangeArray = $api->transactionHistory->range(['from' => '2020-08-01', 'to' => '2020-08-07']);

    $dailyArray = $api->transactionHistory->daily(['date' => '2020-08-07']);

    $weeklyArray = $api->transactionHistory->weekly(['date' => '2020-08-07']);

    $monthlyArray = $api->transactionHistory->monthly(['date' => '2020-08']);

} catch(Exception $e) {
    echo 'There was an exception: '.$e->getMessage();
}
```

#### Credit card transaction query

[](#credit-card-transaction-query)

The credit card transaction query API gives Merchants the ability to query credit card transactions.

```
try {
    $api = new PayFastApi(
        [
            'merchantId' => '10018867',
            'passPhrase' => '2uU_k5q_vRS_',
            'testMode' => true
        ]
    );

    $creditCardArray = $api->creditCardTransactions->fetch('1124148');

} catch(Exception $e) {
    echo 'There was an exception: '.$e->getMessage();
}
```

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

2005d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/750dc17da85c8a836620572d8052dea5bd2bad8898ede35f83de3fe5aa6f0b1d?d=identicon)[klair](/maintainers/klair)

---

Top Contributors

[![klair](https://avatars.githubusercontent.com/u/5232279?v=4)](https://github.com/klair "klair (4 commits)")

---

Tags

phpapipayfastonsite

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/payfastsdk-payfast-php-sdk/health.svg)

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

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[theodo-group/llphant

LLPhant is a library to help you build Generative AI applications.

1.5k311.5k5](/packages/theodo-group-llphant)[payfast/payfast-php-sdk

Payfast PHP Library

32320.5k5](/packages/payfast-payfast-php-sdk)[resend/resend-php

Resend PHP library.

564.7M21](/packages/resend-resend-php)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

553.3M7](/packages/checkout-checkout-sdk-php)

PHPackages © 2026

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