PHPackages                             sevaske/payfort-api - 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. sevaske/payfort-api

ActiveLibrary[Payment Processing](/categories/payments)

sevaske/payfort-api
===================

v1.0.4(4mo ago)1166[2 PRs](https://github.com/sevaske/payfort-api/pulls)1MITPHPPHP ^8.1CI passing

Since Jul 3Pushed 1mo agoCompare

[ Source](https://github.com/sevaske/payfort-api)[ Packagist](https://packagist.org/packages/sevaske/payfort-api)[ GitHub Sponsors](https://github.com/sevaske)[ RSS](/packages/sevaske-payfort-api/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (6)Versions (9)Used By (1)

[![Latest Version on Packagist](https://camo.githubusercontent.com/6667233416274e50f9f36214fb680abf2e4dc333124bcbf4255f4039182fa744/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f73657661736b652f706179666f72742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sevaske/payfort-api)[![Total Downloads](https://camo.githubusercontent.com/0230d3c51adb4949e1d6e31ac4996d6dfb1ef2ca16010497f9c84cf1f89f345a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f73657661736b652f706179666f72742d6170692e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/sevaske/payfort-api)[![PHPUnit](https://github.com/sevaske/payfort-api/actions/workflows/run-tests.yml/badge.svg)](https://github.com/sevaske/payfort-api/actions/workflows/run-tests.yml)[![PHPStan](https://github.com/sevaske/payfort-api/actions/workflows/phpstan.yml/badge.svg)](https://github.com/sevaske/payfort-api/actions/workflows/phpstan.yml)

Payfort API PHP Client
======================

[](#payfort-api-php-client)

A simple and extensible PSR-18 compatible PHP client for working with [Amazon Payment Services (Payfort)](https://paymentservices.amazon.com/).

#### Note:

[](#note)

1. This version is currently in beta. Use at your own risk.
2. This package requires a PSR-18 compatible HTTP client and PSR-17 factories. For example, you can use Guzzle:

```
composer require guzzlehttp/guzzle nyholm/psr7
```

Features
--------

[](#features)

- PSR-18 HTTP client support
- PSR-7 request/response
- Signature verification
- Custom command support
- Exception handling with context
- Easily debug request/response payloads

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

[](#requirements)

- PHP ^8.1
- PSR-18 HTTP client (psr/http-client)
- PSR-7 HTTP messages (psr/http-message)
- PSR-17 HTTP factories (optional, if required by your HTTP client)

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

[](#installation)

Install via [Composer](https://getcomposer.org):

```
composer require sevaske/payfort-api
```

Usage
-----

[](#usage)

```
use Sevaske\PayfortApi\Credential;
use Sevaske\PayfortApi\Merchant;
use Sevaske\PayfortApi\Http\Responses\CheckStatusResponse;

// Setup credentials
$credential = new Credential(
    'merchantIdentifier',
    'accessCode',
    'shaRequestPhrase',
    'shaResponsePhrase',
);

// Use any PSR-18 compatible HTTP client
$httpClient = new \GuzzleHttp\Client(); // or any other PSR-18 client

// Create merchant instance
$merchant = new Merchant('sandbox', $httpClient, $credential);

// Simple status check
$response = $merchant->api()->checkStatus('12345'); // CheckStatusResponse
```

#### Available API methods

[](#available-api-methods)

The following methods are available for use:

```
$merchant->api()->checkStatus(); // Check the status of a transaction
$merchant->api()->recurring(); // Purchase
$merchant->api()->voidAuthorization(); // Void an authorization
$merchant->api()->refund(); // Process a refund
$merchant->api()->createToken(); // Create a new payment token
$merchant->api()->updateToken(); // Update an existing payment token
```

#### Debugging with callback

[](#debugging-with-callback)

```
$response = $merchant->api()->checkStatus('12345', callback: function (
    CheckStatusResponse $response,
    array $request
) {
    $request;                      // Raw request data
    $response->jsonSerialize();    // Parsed response as array
    $response->authorizedAmount(); // ?string
    $response->capturedAmount();   // ?string
    $response->refundedAmount();   // ?string

    return $response;
});
```

#### Custom command request

[](#custom-command-request)

```
$response = $merchant->api()->request([
    'command' => 'CUSTOM',
]); // Returns generic Response
```

#### Error handling

[](#error-handling)

```
use Sevaske\PayfortApi\Exceptions\PayfortException;
use Sevaske\PayfortApi\Exceptions\PayfortRequestException;
use Sevaske\PayfortApi\Exceptions\PayfortResponseException;
use Sevaske\PayfortApi\Exceptions\PayfortSignatureException;

try {
    $response = $merchant->api()->refund('12345', 1000, 'SAR'); // RefundResponse
} catch (PayfortRequestException $e) {
    // Request could not be sent
} catch (PayfortResponseException $e) {
    // Received an invalid response
} catch (PayfortSignatureException $e) {
    // Signature mismatch
}

// or "catch-all" exception handling
try {
    $response = $merchant->api()->refund('12345', 1000, 'SAR');
} catch (PayfortException $e) {
    $context = $e->context();
}
```

Future functionality
--------------------

[](#future-functionality)

In the future, you will be able to handle redirection requests:

```
$merchant->redirection()->...; // Example of future functionality
```

🧪 Testing
---------

[](#-testing)

```
composer test
```

📜 Changelog
-----------

[](#-changelog)

See [CHANGELOG.md](CHANGELOG.md) for recent changes.

⚖ License
---------

[](#-license)

MIT. See [LICENSE](LICENSE) for details.

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance84

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 86% 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 ~37 days

Total

6

Last Release

132d ago

Major Versions

0.2.0 → v1.0.02025-07-25

### Community

Maintainers

![](https://www.gravatar.com/avatar/94643c38672a39a9b675ab6d43f5c1d3c0789300cc052f742a960e0a7d70847e?d=identicon)[sevaske](/maintainers/sevaske)

---

Top Contributors

[![sevaske](https://avatars.githubusercontent.com/u/42838184?v=4)](https://github.com/sevaske "sevaske (43 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (5 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (2 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sevaske-payfort-api/health.svg)

```
[![Health](https://phpackages.com/badges/sevaske-payfort-api/health.svg)](https://phpackages.com/packages/sevaske-payfort-api)
```

###  Alternatives

[chargebee/chargebee-php

ChargeBee API client implementation for PHP

768.0M9](/packages/chargebee-chargebee-php)[superfaktura/apiclient

Api client for SuperFaktura | online invoicing tool

19133.3k](/packages/superfaktura-apiclient)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

245.2k](/packages/aedart-athenaeum)[sevaske/php-zatca-xml

An unofficial PHP library for generating ZATCA Fatoora e-invoices. This library facilitates the creation of compliant e-invoices, QR Codes, and certificates, as well as the submission of e-invoices to ZATCA's servers. It provides developers with an easy-to-use, customizable, and robust toolkit to integrate and automate ZATCA e-invoicing processes in PHP applications.

193.3k1](/packages/sevaske-php-zatca-xml)

PHPackages © 2026

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