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

ActiveLibrary[API Development](/categories/api)

zfhassaan/payfast
=================

Laravel 9 Package for Payfast Payment Gateway

v1.0.7(2mo ago)65887MITPHPPHP ^7.4|^8.0CI passing

Since Oct 22Pushed 2mo ago1 watchersCompare

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

READMEChangelog (8)Dependencies (4)Versions (10)Used By (0)

 [![PayFast Payment Gateway](logo.png)](logo.png)

[![Laravel Versions](https://camo.githubusercontent.com/442a0214917f38b20447421aa03591adff97e06b7c364d13059adb7afca18170/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c61726176656c2d392532302537432532303130253230253743253230313125323025374325323031322d4646324432303f7374796c653d666c61742d737175617265266c6f676f3d6c61726176656c)](https://packagist.org/packages/zfhassaan/payfast)[![Latest Version on Packagist](https://camo.githubusercontent.com/209d40e8b71057f74eb844060c8823fe4078e0fd02c23b48a1c7dfdb8ace5f9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a666861737361616e2f706179666173742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zfhassaan/payfast)[![MIT Licensed](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/8d25de9feab7c3041b9e90d52642a772880f161197b4fd47acb2c81f2c7c8b65/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7a666861737361616e2f706179666173742e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/zfhassaan/payfast)[![Code Style](https://camo.githubusercontent.com/3b3c737aea496c6e1d101e71596a571b3cb6f4e999ae19f620f7c7a1a211ba23/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f64652532307374796c652d70696e742d6f72616e67653f7374796c653d666c61742d737175617265)](https://github.com/zfhassaan/payfast)[![Tests](https://camo.githubusercontent.com/9f8cea33a7b135e001fcb8b24fbb19d5f90cff059a77042383f05bd6a37f0866/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f7a666861737361616e2f706179666173742f74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d7465737473)](https://github.com/zfhassaan/payfast/actions/workflows/tests.yml)[![Hits](https://camo.githubusercontent.com/6810ecb2cc7e09069ce32e686d284958da6c1c0396ba806280cd51557a859ead/68747470733a2f2f686974732e736565796f756661726d2e636f6d2f6170692f636f756e742f696e63722f62616467652e7376673f75726c3d68747470732533412532462532466769746875622e636f6d2532467a666861737361616e2532467061796661737426636f756e745f62673d253233373943383344267469746c655f62673d2532333535353535352669636f6e3d7765626d6f6e65792e7376672669636f6e5f636f6c6f723d253233453745374537267469746c653d4869747326656467655f666c61743d66616c7365)](https://hits.seeyoufarm.com)

####  Disclaimer

[](#-disclaimer-)

This is unofficial Payfast API Payment Gateway. This repository is only created to help developers in streamlining the integration process. You can Review the Official Payment Gateway [here.](https://gopayfast.com/docs/#preface)This Package only covers direct checkout and hosted checkout process. There's no Subscription option enabled yet it'll be added in the next build.

#### About

[](#about)

This document contains detailed explanation about how to integrate with Payfast API's Based transactions functionality. This document also contains the details for online transaction. v1.0.0

#### Intended Audience

[](#intended-audience)

This document is for merchants acquires and developers who want to integrate with Payfast to perform a API's based Transaction.

#### Integration Scope

[](#integration-scope)

The merchant will implement all ecommerce functionality. PayFast service (PayFast) will be used only payment processing.

#### API End Points

[](#api-end-points)

This section contains the details of all APIs provided by Payfast. These APIs could be called by the merchants, acquirers and/or aggregators. These APIs are based on REST architecture and serve standard HTTP codes for the response payload.

#### Integration Prerequisites

[](#integration-prerequisites)

Merchants will be registered on PayFast prior to integration. After merchant sign up for PayFast account, following two unique values will be provided to merchant to operate: *Merchant\_ID* and *Secured\_key* , these keys are used to get a one-time authentication token, which is used to authenticate payment requests to the "PayFast"payment gateway.

#### Installation

[](#installation)

You can install the package via composer

```
composer require zfhassaan/payfast

```

#### Set .env configurations

[](#set-env-configurations)

```
PAYFAST_API_URL=
PAYFAST_SANDBOX_URL=
PAYFAST_GRANT_TYPE=
PAYFAST_MERCHANT_ID=
PAYFAST_MODE=
PAYFAST_SECURED_KEY=
PAYFAST_RETURN_URL=

```

#### configuration

[](#configuration)

Add These files in `app/config.php`

```
  /*
    * Package Service Providers...
    */

  \zfhassaan\Payfast\PayfastServiceProvider::class,
```

and also in alias in `app/config.php`

```
  'aliases' => Facade::defaultAliases()->merge([
        'Payfast' => \zfhassaan\Payfast\Facade\Payfast::class,
    ])->toArray(),
```

#### Steps

[](#steps)

##### Direct Checkout

[](#direct-checkout)

1. Get Authentication Token
2. Validate Customer Information.
3. Initiate Transaction

##### Hosted Checkout

[](#hosted-checkout)

1. Get Authentication Token
2. Initiate Transaction on Payfast Page.

The Direct Checkout and Hosted checkout credentials can be obtained from [Payfast](https://gopayfast.com/) The following are direct checkout methods that can be used with PCIDSS certified websites. You can read more about how to initiate Hosted checkout in the [documentation](docs/content/Understanding-the-Hosted-Checkout-Process-for-Payfast.md).

##### What is PCI DSS Certified.

[](#what-is-pci-dss-certified)

PCI certification ensures the security of card data at your business through a set of requirements established by the PCI SSC. These include a number of commonly known best practices, such as: Installation of firewalls. Encryption of data transmissions, use of anti-virus software. In addition businesses must restrict access to cardholder data and monitor access to network resources.

PCI-compliant security provides a valuable asset that informs customers that your business is safe to transact with. Conversely, the cost of noncompliance, both in monetary and reputational terms, should be enough to convince any business owner to take data security seriously.

A data breach that reveals sensitive customer information is likely to have severe repercussions on an enterprise. A breach may result in fines from payment card issuers, lawsuits, diminished sales and a severely damaged reputation.

After experiencing a breach, a business may have to cease accepting credit card transactions or be forced to pay higher subsequent charges than the initial cost of security compliance. The investment in PCI security procedures goes a long way toward ensuring that other aspects of your commerce are safe from malicious online actors.

##### Hosted Checkout

[](#hosted-checkout-1)

The Hosted checkout requires to follow following steps;

1. Get Authentication Token from Payfast
2. Create signature with md5 standard `md5($merchant_id.':' . $merchant_name.':'.$amount.':'.$order_id)`
3. Create Payload for website. The website payload will look something like this:

```
...
...
$backend_callback = "signature=".$signature."&order_id=".$order_id;
...
...
$payload = array(
            'MERCHANT_ID' => $merchant_id, // Merchant ID received from Payfast
            'MERCHANT_NAME' => $merchant_name, // Merchant Name registered with Payfast.
            'TOKEN' => $ACCESS_TOKEN, // Access Token received from Payfast.
            'PROCCODE' => 00, // status code default is 00
            'TXNAMT' => $amount, // Transaction Amount or total amount
            'CUSTOMER_MOBILE_NO' => $mobile, // Customer Mobile Number
            'CUSTOMER_EMAIL_ADDRESS' => $email, // Customer Email address
            'SIGNATURE' => $signature, // Signature as described in above step 2.
            'VERSION' => 'WOOCOM-APPS-PAYMENT-0.9', // Optional
            'TXNDESC' => 'Products purchased from ' .$merchant_name, // Transaction Description to show on website
            'SUCCESS_URL' => urlencode($successUrl), // Success URL where to redirect user after success
            'FAILURE_URL' => urlencode($failUrl), // Failure URL where to redirect user after failure
            'BASKET_ID' => $order_id, // Order ID from Checkout Page.
            'ORDER_DATE' => date('Y-m-d H:i:s', time()), // Order Date
            'CHECKOUT_URL' => urlencode($backend_callback), // Encrypted Checkout URL
        );

```

4. Submit it on Payfast provided URL.

#### Usage

[](#usage)

```
use zfhassaan\Payfast\Payfast;
...
...

/**
 * Validate Customer and get OTP Screen.
 * Step 1
 */
public function checkout(Request $request) {
  $payfast = new Payfast();
  $response = $payfast->getToken();
  if($response != null && $response->code == "00" ){
      $payfast->setAuthToken($response->token);
  } else {
      abort(403, 'Error: Auth Token Not Generated.');
  }
  $show_otp = $payfast->customer_validate($request->all());
  return $show_otp;
}

/**
 * Receive 3ds PaRes from Callback.
 * This will be called on Callback from OTP Screen.
 * You can Show Proceed to Payment Screen or Complete Transaction Screen.
 * Step 2
 */
public function callback(Request $request) {
    return response()->json($request->all());
}

/**
 * Send a request again with Required Params and complete the transaction
 * Proceed to Payment and complete Transaction
 * Step 3
 */
public function proceed(Request $request) {
  $payfast = new Payfast();
  $response = $payfast->initiate_transaction($request);
  return $response;
}

/**
 * Mobile Wallet Account Initiate Transaction
 * This is demo function for Easy Paisa.
 *
 */

public function payfast(Request $request)
{
    $payfast = new Payfast();
    $response = $payfast->getToken();
    if($response != null && $response->code == "00" ){
        $payfast->setAuthToken($response->token);
    } else {
        abort(403, 'Error: Auth Token Not Generated.');
    }
    $show_otp = $payfast->wallet($request->all());
    return $show_otp;
}
```

#### Changelog

[](#changelog)

Please see Changelog for more information what has changed recently.

#### Security

[](#security)

The following lines are taken from [briandk](https://gist.github.com/briandk/3d2e8b3ec8daf5a27a62) repository for contributing in an open source projects.

**Great Bug Reports** tend to have:

- A quick summary and/or background
- Steps to reproduce
    - Be specific!
    - Give sample code if you can. An issue includes sample code that *anyone* with a base R setup can run to reproduce what I was seeing
- What you expected would happen
- What actually happens
- Notes (possibly including why you think this might be happening, or stuff you tried that didn't work)

#### License

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

47

—

FairBetter than 94% of packages

Maintenance83

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 97.3% 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 ~173 days

Recently: every ~243 days

Total

8

Last Release

86d ago

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

v1.0.5PHP ^7.4|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/3f91e22a64582fa1db957f7f189736d6cd2e6f1f69c2236a42a9ee8fcbdd0723?d=identicon)[zfhassaan](/maintainers/zfhassaan)

---

Top Contributors

[![zfhassaan](https://avatars.githubusercontent.com/u/17079656?v=4)](https://github.com/zfhassaan "zfhassaan (73 commits)")[![UsamaAnwar1](https://avatars.githubusercontent.com/u/40737492?v=4)](https://github.com/UsamaAnwar1 "UsamaAnwar1 (2 commits)")

---

Tags

laravellaravel-frameworkpakistanpayfastpaymentpayment-gatewaypaymentstransactionphpapilaravelpaymentpayfastdocs

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[dingo/blueprint

API Blueprint documentation generator.

2707.8M22](/packages/dingo-blueprint)[resend/resend-laravel

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[joisarjignesh/bigbluebutton

BigBlueButton Server API Library for Laravel

162145.5k1](/packages/joisarjignesh-bigbluebutton)[dariusiii/tmdb-laravel

Laravel Package for TMDB ( The Movie Database ) API. Provides easy access to the wtfzdotnet/php-tmdb-api library.

1821.1k](/packages/dariusiii-tmdb-laravel)[dystcz/lunar-api

Dystore API layer for Lunar e-commerce package

411.1k3](/packages/dystcz-lunar-api)

PHPackages © 2026

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