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 ensures that you receive real-time updates on transaction status changes, such as successful payments, rejections, or errors.

The Pesapal SDK requires a notification_id to associate with every transaction, and this is only generated after the IPN URL is registered.


Key Points:

  1. Mandatory Step: You must register the IPN URL before any transaction to obtain the notification_id.
  2. Storage: The notification_id is automatically stored in pesapal_dynamic.json after successful registration.
  3. Publicly Accessible URL: The IPN URL must be publicly accessible and should not be blocked by any server firewall rules.
  4. Whitelisting Pesapal: If your server has strict rules, ensure to whitelist calls from the Pesapal domain (pesapal.com).

Proceed to Register Your IPN URL Below:

Register IPN URL

Registering an IPN (Instant Payment Notification) URL is a crucial step to receive real-time updates on transaction status changes, such as payment completion, rejection, or errors.

To understand how to implement this, refer to the example file provided:
example/register_ipn.php.


Illustration: IPN Registration Process


Note: Ensure your IPN URL is publicly accessible and correctly configured to handle incoming notifications from Pesapal.

Submit Order

To create and submit a payment request to Pesapal, you need to prepare order data that includes billing details, transaction description, and callback URLs. The SDK ensures all required fields are formatted correctly, including validating phone numbers and generating the necessary access_token.

Note: A valid notification_id must be registered before submitting the payment request. Let's hope you already done that. Refer to the Register IPN URL section.


Example Usage:

The following example demonstrates how to prepare and submit a payment request:

``

Get Transaction Status

After the transaction is completed, use the OrderTrackingId to check the transaction status.

`

Recurring Payments

Set up subscription-based payments for recurring charges using Pesapal. The SDK supports specifying subscription details such as start and end dates and frequency. It also includes validations for subscription details and formatting for dates and billing information.


Example Usage:

The following example demonstrates how to prepare and submit a recurring payment request:

Refund Request

Requesting a refund for a completed transaction is straightforward with the SDK. The SDK automatically checks the transaction status using the order_tracking_id before submitting a refund request. If the transaction status is not COMPLETED, the SDK throws an error to prevent invalid refund attempts.


How It Works:

  1. The SDK retrieves the transaction status using the provided order_tracking_id.
  2. If the transaction is COMPLETED, the SDK prepares and submits the refund request automatically.
  3. If the transaction is not COMPLETED, the SDK throws an error indicating that the refund request cannot proceed.

Example Usage:

Get Transaction Status

After a transaction is completed, you can check its status using the order_tracking_id. This is useful to confirm whether a payment was successful, failed, or is still pending.

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