Download the PHP package katorymnd/pesapal-php-sdk without Composer

On this page you can find all versions of the php package katorymnd/pesapal-php-sdk. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package pesapal-php-sdk

Pesapal PHP SDK

The Pesapal PHP SDK provides a simple and efficient way to integrate the Pesapal Payment Gateway into your PHP application. This SDK handles authentication, order submission, transaction status checks, recurring payments, and refunds, making it easier for developers to interact with Pesapal's API 3.0.

Table of Contents

Features

Requirements

Installation

Use Composer to install the Pesapal PHP SDK:

Configuration

  1. Clone the Repository (if not using Composer):

  2. Install Dependencies:

    Navigate to the project directory and install dependencies:

  3. Set Up Environment Variables:

    • Copy the .env.example file to .env:

    • Open the .env file and set your Pesapal consumer_key and consumer_secret:
  4. Ensure pesapal_dynamic.json is Writable:

    The SDK uses pesapal_dynamic.json to store the access_token and other dynamic data. Make sure this file is writable by your application.

Usage

Authentication

The SDK automatically handles authentication with Pesapal. Upon initialization, the SDK retrieves the access_token using your configured consumer_key and consumer_secret. The token is valid for 5 minutes and is securely stored in pesapal_dynamic.json.

You don't need to manually request or manage the access_token; the SDK ensures it is always available and refreshed as needed for API calls.


How it Works:

  1. When you make an API call, the SDK checks for a valid access_token in pesapal_dynamic.json.
  2. If the token is expired or unavailable, the SDK automatically re-authenticates with Pesapal and updates pesapal_dynamic.json.

Important Notice: IPN Registration

Before initiating any transactions, it is mandatory to register an IPN (Instant Payment Notification) URL. This allows your application to receive real-time updates on payment status, such as successful payments, failures, or reversals.

But here's where this SDK shines: it automatically handles IPN registration smartly based on your environment (sandbox or production) — making it easier to avoid common mistakes.


🔍 How IPN Registration Works Behind the Scenes

When the SDK initializes (e.g., via submit_order.php or register_ipn.php), it follows this logic:

  1. Reads pesapal_dynamic.json to load your previously registered IPN URL and notification_id.
  2. Checks if the current environment (sandbox or production) matches the token_env (also saved in pesapal_dynamic.json).
  3. If the environment has changed, or if the IPN URL does not match what Pesapal has on record, it:

    • Automatically registers the correct IPN URL with Pesapal for the active environment using the already available IPN URL in your pesapal_dynamic.json.

    • Updates the file pesapal_dynamic.json with the new notification_id, access_token, and environment tag (token_env).
  4. You don’t need to manually update this again – it’s handled for you.

🛠️ Configure for Sandbox or Production

At the top of each example (e.g., register_ipn.php, submit_order.php), you’ll find this block:

Switch to production like this:


✅ What You Need to Do


Why This Matters:

Pesapal assigns different notification IDs depending on the environment. If you use a sandbox notification_id in production (or vice versa), your payment callbacks may fail. This SDK prevents that error for you.


Register IPN URL

Refer to: example/register_ipn.php

This script demonstrates how to register an IPN URL and retrieve the notification_id required for all transactions.

Submit Order

See usage section for code sample…

Get Transaction Status

Recurring Payments

See usage section for code sample…

Refund Request

See usage section for code sample…

Get Transaction Status

See usage section for code sample…

Tutorials and Guides

Embark on your journey with the Pesapal PHP SDK through our exclusive tutorials and guides:

Testing Environment Setup

For testing and development purposes, utilize the test cards provided by Pesapal at the following URL:

https://cybqa.pesapal.com/PesapalIframe/PesapalIframe3/TestPayments

License

This project is licensed under the MIT License - see the LICENSE file for details.


Disclaimer: This SDK is not an official Pesapal product. It's an independent project aimed at simplifying Pesapal API integration for PHP developers. For any issues related to the Pesapal API itself, please contact Pesapal Support.


All versions of pesapal-php-sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0.0
guzzlehttp/guzzle Version ^7.9
vlucas/phpdotenv Version ^5.6
monolog/monolog Version ^3.7
filp/whoops Version ^2.16
giggsey/libphonenumber-for-php Version ^8.13
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package katorymnd/pesapal-php-sdk contains the following files

Loading the files please wait ....