PHPackages                             douglastycho/payfast-php-sdk-php71 - 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. douglastycho/payfast-php-sdk-php71

ActiveLibrary[API Development](/categories/api)

douglastycho/payfast-php-sdk-php71
==================================

PayFast PHP Library

v1.0.0(3y ago)04MITPHPPHP &gt;=7.1

Since Aug 26Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (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 payfast/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.

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

```
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.

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

```
// Include:

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.

See the [Developer Docs](https://developers.payfast.co.za/api#recurring-billing)

```
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();
}
```

#### Update card

[](#update-card)

The update card endpoint allows you to provide buyers with a link to update their card details on a Recurring Billing subscription or Tokenization charges.

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

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

    echo $payfast->custom->createCardUpdateLink('2afa4575-5628-051a-d0ed-4e071b56a7b0', 'https://www.example.com/return', 'Update your card', ['target' => '_blank']);

} 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.

See the [Developer Docs](https://developers.payfast.co.za/api#transaction-history)

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

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

    $dailyArray = $api->transactionHistory->daily(['date' => '2020-08-07', 'offset' => 0, 'limit' => 1000]);

    $weeklyArray = $api->transactionHistory->weekly(['date' => '2020-08-07', 'offset' => 0, 'limit' => 1000]);

    $monthlyArray = $api->transactionHistory->monthly(['date' => '2020-08', 'offset' => 0, 'limit' => 1000]);

} 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.

See the [Developer Docs](https://developers.payfast.co.za/api#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();
}
```

#### Refunds

[](#refunds)

The Refunds API Providing gives Merchants the ability to perform refunds on their account.

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

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

    $refundFetchArray = $api->refunds->fetch('dc0521d3-55fe-269b-fa00-b647310d760f');

    $refundCreateArray = $api->refunds->create('dc0521d3-55fe-269b-fa00-b647310d760f', ['amount' => 50, 'reason' => 'Product returned', 'acc_type' => 'savings']);

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

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

1353d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dadb90ab2f39b6083b3df21a9aa634156ae529bb84e056f06a014d82920ed71?d=identicon)[douglastycho](/maintainers/douglastycho)

---

Top Contributors

[![clairepf](https://avatars.githubusercontent.com/u/68599211?v=4)](https://github.com/clairepf "clairepf (11 commits)")[![PieterE-PF](https://avatars.githubusercontent.com/u/109581616?v=4)](https://github.com/PieterE-PF "PieterE-PF (7 commits)")[![douglastycho](https://avatars.githubusercontent.com/u/7977967?v=4)](https://github.com/douglastycho "douglastycho (6 commits)")[![lefu007](https://avatars.githubusercontent.com/u/10028848?v=4)](https://github.com/lefu007 "lefu007 (1 commits)")

---

Tags

phpapipayfastonsite

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  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)
