Pesapal Omnipay gateway

v1.0.0-alpha1 2016-01-27 15:56 UTC

This package is auto-updated.

Last update: 2024-05-11 08:41:24 UTC


Skeleton gateway for the Omnipay PHP payment processing library

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Omnipay is a framework agnostic, multi-gateway payment processing library for PHP 5.3+. This package implements pesapal support for Omnipay.

This is where your description should go. Try and limit it to a paragraph or two, and maybe throw in a mention of what PSRs you support to avoid any confusion with users and contributors.


Via Composer

$ composer require fruitcakestudio/omnipay-pesapal:"1.x@alpha"


The following gateways are provided by this package:

  • Pesapal

For general usage instructions, please see the main Omnipay repository.



require 'vendor/autoload.php';

$gateway = \Omnipay\Omnipay::create('Pesapal');
    'key' => 'your-consumer-key',
    'secret' => 'your-consumer-secret',
    'testMode' => false,


require 'bootstrap.php';

// Make a purchase request
$response = $gateway->purchase(array(
    'amount' => "6.84",
    'description' => "Testorder #1234",
    'currency' => 'USD',
    'card' => array(
        'email' => '',
        'firstName' => 'Barry',
        'lastName' => 'vd. Heuvel',
        'phone' => '+1234567890',
    'returnUrl' => '',

$transactionId = $response->getTransactionId();

if ($response->isRedirect()) {
    // redirect to offsite payment gateway
} else {
    // payment failed: display message to customer
    echo "Error " .$response->getCode() . ': ' . $response->getMessage();


require 'bootstrap.php';

// Check the payment status
$response = $gateway->completePurchase()->send();

// Show status to user
if ($response->isSuccessful()) {
    echo "Transaction '" . $response->getTransactionId() . "' succeeded!";
} else {
    echo "Status: " .$response->getCode() . ': ' . $response->getMessage();


require 'bootstrap.php';

// Check the payment status
$response = $gateway->completePurchase()->send();

$reference = $response->getTransactionReference();  // TODO; Check the reference/id with your database
$transactionId = $response->getTransactionId();

   // Save state

// Return message for the gateway
echo $response->getNotificationMessage();   // Or ->getNotificationResponse() for Symfony Response

The transactionReference is pesapal_transaction_tracking_id, which is set by Pesapal. The transactionId is your own id (pesapal_merchant_reference), which will be generated if not provided.

See the documentation on

Sandbox / Demo

When you set testMode to true, the Demo sandbox will be used.

You need a different consumer key/secret. Follow these steps to use the testMode:

  • Create a business account on
  • Login to your demo account, the key/secret are on the dashboard.
  • Start a transaction and send dummy money
  • Use the same phonenumber (eg. 700123456) and amount. Copy the confirmation code after submitting.


If you are having general issues with Omnipay, we suggest posting on Stack Overflow. Be sure to add the omnipay tag so it can be easily found.

If you want to keep up to date with release anouncements, discuss ideas for the project, or ask more detailed questions, there is also a mailing list which you can subscribe to.

If you believe you have found a bug, please report it using the GitHub issue tracker, or better yet, fork the library and submit a pull request.

Change log

Please see CHANGELOG for more information what has changed recently.


$ composer test


Please see CONTRIBUTING for details.


If you discover any security related issues, please email instead of using the issue tracker.



The MIT License (MIT). Please see License File for more information.