PHPackages                             codevirtus/pesepay - 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. codevirtus/pesepay

ActiveLibrary[Payment Processing](/categories/payments)

codevirtus/pesepay
==================

Pesepay online payment integration package

1.0.1(4y ago)18.9k↑40%32MITPHPPHP ^7.4|^8.0CI failing

Since Oct 22Pushed 2d agoCompare

[ Source](https://github.com/codevirtus/pesepay-php)[ Packagist](https://packagist.org/packages/codevirtus/pesepay)[ Docs](https://github.com/codevirtus/pesepay)[ RSS](/packages/codevirtus-pesepay/feed)WikiDiscussions master Synced yesterday

READMEChangelog (2)Dependencies (1)Versions (4)Used By (2)

PesePay PHP SDK
===============

[](#pesepay-php-sdk)

A simple PHP SDK for integrating **PesePay** payments into your application.

---

Installation
============

[](#installation)

Install the package via Composer:

```
composer require codevirtus/pesepay
```

---

Getting Started
===============

[](#getting-started)

1. Import the SDK
-----------------

[](#1-import-the-sdk)

```
require_once 'vendor/autoload.php';

use Codevirtus\Payments\Pesepay;
```

2. Initialize the Client
------------------------

[](#2-initialize-the-client)

Create a new `Pesepay` instance using the credentials provided by PesePay.

```
$pesepay = new Pesepay(
    "INTEGRATION_KEY",
    "ENCRYPTION_KEY"
);
```

3. Configure Callback URLs
--------------------------

[](#3-configure-callback-urls)

Set the URLs that PesePay will use after processing a payment.

```
$pesepay->returnUrl = "https://example.com/gateway/return";
$pesepay->resultUrl = "https://example.com/gateway/result";
```

- **returnUrl** – Where the customer is redirected after completing payment.
- **resultUrl** – Endpoint that receives the payment result.

---

Seamless Payments
=================

[](#seamless-payments)

Seamless payments allow customers to complete payment directly within your application.

Step 1: Create a Payment
------------------------

[](#step-1-create-a-payment)

> **Note:** Either the customer's email address or phone number must be provided.

```
$payment = $pesepay->createPayment(
    'CURRENCY_CODE',
    'PAYMENT_METHOD_CODE',
    'CUSTOMER_EMAIL',          // Optional
    'CUSTOMER_PHONE_NUMBER',   // Optional
    'CUSTOMER_NAME'            // Optional
);
```

---

Step 2: Provide Required Payment Fields
---------------------------------------

[](#step-2-provide-required-payment-fields)

Different payment methods require different fields.

### Visa

[](#visa)

```
$requiredFields = [
    "creditCardExpiryDate" => "09/23",
    "creditCardNumber" => "4867960000005461",
    "creditCardSecurityNumber" => "608"
];
```

### Mobile Money (EcoCash, InnBucks, etc.)

[](#mobile-money-ecocash-innbucks-etc)

```
$requiredFields = [
    "customerPhoneNumber" => "0712345678"
];
```

---

Step 3: Submit the Payment
--------------------------

[](#step-3-submit-the-payment)

```
$response = $pesepay->makeSeamlessPayment(
    $payment,
    'Online Transaction',
    $AMOUNT,
    $requiredFields,
    'MERCHANT_REFERENCE' // Optional
);

if ($response->success()) {

    // Store these values to check payment status later
    $referenceNumber = $response->referenceNumber();
    $pollUrl = $response->pollUrl();

    // Transaction details
    $amount = $response->amount();
    $currencyCode = $response->currencyCode();
    $transactionFee = $response->transactionServiceFee();
    $metaData = $response->transactionMetadata();

    // Full API response
    $data = $response->rawData();

    // InnBucks-specific data
    $code = $response->metadataCode();
    $qrcode = $response->metadataQrCode();

} else {

    $errorMessage = $response->message();

}
```

---

Redirect Payments
=================

[](#redirect-payments)

Redirect payments send the customer to the PesePay checkout page to complete payment.

Step 1: Create a Transaction
----------------------------

[](#step-1-create-a-transaction)

```
$transaction = $pesepay->createTransaction(
    $amount,
    'CURRENCY_CODE',
    'PAYMENT_REASON',
    'MERCHANT_REFERENCE' // Optional
);
```

---

Step 2: Initiate the Transaction
--------------------------------

[](#step-2-initiate-the-transaction)

```
$response = $pesepay->initiateTransaction($transaction);

if ($response->success()) {

    // Save these values for future payment status checks
    $referenceNumber = $response->referenceNumber();
    $pollUrl = $response->pollUrl();

    // Redirect the customer
    $redirectUrl = $response->redirectUrl();

} else {

    $errorMessage = $response->message();

}
```

---

Checking Payment Status
=======================

[](#checking-payment-status)

You can verify a payment using either the transaction reference number or the poll URL returned when the payment was created.

Option 1: Check by Reference Number
-----------------------------------

[](#option-1-check-by-reference-number)

```
$response = $pesepay->checkPayment($referenceNumber);

if ($response->success()) {

    if ($response->paid()) {
        // Payment successful
    }

} else {

    $errorMessage = $response->message();

}
```

---

Option 2: Check by Poll URL
---------------------------

[](#option-2-check-by-poll-url)

```
$response = $pesepay->pollTransaction($pollUrl);

if ($response->success()) {

    if ($response->paid()) {
        // Payment successful
    }

} else {

    $errorMessage = $response->message();

}
```

---

Response Methods
================

[](#response-methods)

Most SDK responses provide the following helper methods:

MethodDescription`success()`Returns `true` if the request completed successfully.`message()`Returns the error message if the request failed.`referenceNumber()`Returns the PesePay transaction reference.`pollUrl()`Returns the polling URL used to check payment status.`amount()`Returns the transaction amount.`currencyCode()`Returns the transaction currency.`transactionServiceFee()`Returns the service fee charged.`transactionMetadata()`Returns additional transaction metadata.`rawData()`Returns the complete API response.`metadataCode()`Returns the InnBucks payment code (where applicable).`metadataQrCode()`Returns the InnBucks QR code (where applicable).`redirectUrl()`Returns the checkout URL for redirect payments.`paid()`Returns `true` if the payment has been completed successfully.

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance65

Regular maintenance activity

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 62.5% 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 ~0 days

Total

2

Last Release

1715d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/92911652?v=4)[Code Virtus](/maintainers/codevirtus)[@codevirtus](https://github.com/codevirtus)

---

Top Contributors

[![sean-codevirtus](https://avatars.githubusercontent.com/u/92912881?v=4)](https://github.com/sean-codevirtus "sean-codevirtus (10 commits)")[![gitnyasha](https://avatars.githubusercontent.com/u/45620987?v=4)](https://github.com/gitnyasha "gitnyasha (4 commits)")[![codevirtus-dev](https://avatars.githubusercontent.com/u/248852814?v=4)](https://github.com/codevirtus-dev "codevirtus-dev (1 commits)")[![simbachizhande](https://avatars.githubusercontent.com/u/93269083?v=4)](https://github.com/simbachizhande "simbachizhande (1 commits)")

---

Tags

codevirtuspesepay

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/codevirtus-pesepay/health.svg)

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

###  Alternatives

[msilabs/bkash

bKash Payment Gateway API for Laravel Framework.

181.2k](/packages/msilabs-bkash)

PHPackages © 2026

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