PHPackages                             ctechpay/ctechpay-php - 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. ctechpay/ctechpay-php

ActiveLibrary

ctechpay/ctechpay-php
=====================

Official PHP SDK for CtechPay hosted payments, Airtel Money, and card status checks.

v1.0.0(1mo ago)14↓66.7%MITPHPPHP ^8.1

Since Jul 17Pushed 1w agoCompare

[ Source](https://github.com/Laughwellreformed/ctechpay-php)[ Packagist](https://packagist.org/packages/ctechpay/ctechpay-php)[ RSS](/packages/ctechpay-ctechpay-php/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (1)Versions (2)Used By (0)

CtechPay PHP SDK
================

[](#ctechpay-php-sdk)

Official PHP SDK for integrating CtechPay payments in PHP and Laravel applications.

Use this package from your server. Your CtechPay service token must never be exposed in browser JavaScript, mobile apps, or public repositories.

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

[](#installation)

```
composer require ctechpay/ctechpay-php
```

Basic Usage
-----------

[](#basic-usage)

```
use CtechPay\CtechPay;

$ctechpay = CtechPay::client('YOUR_SERVICE_TOKEN');
```

You can also configure the API base URL and request timeout:

```
$ctechpay = CtechPay::client('YOUR_SERVICE_TOKEN', [
    'base_url' => 'https://new-api.ctechpay.com',
    'timeout' => 30,
]);
```

Hosted Payment Page
-------------------

[](#hosted-payment-page)

Hosted checkout is the recommended integration for most merchants. CtechPay gives you a secure payment page where the customer can choose Airtel Money or card.

```
$payment = $ctechpay->hostedPayments()->create([
    'amount' => 100,
    'category_flag' => 'LOAN_APPLICATION',
    'customer_reference' => 'INV-1001',
    'customer_message' => 'Invoice payment',
    'customer_name' => 'Jane Doe',
    'customer_email' => 'jane@example.com',
    'redirectUrl' => 'https://example.com/payments/success',
    'cancelUrl' => 'https://example.com/payments/cancelled',
]);

header('Location: ' . $payment['data']['hosted_payment_url']);
exit;
```

### Hosted Redirect Reference

[](#hosted-redirect-reference)

When a hosted payment completes successfully, CtechPay redirects the customer to your `redirectUrl` with a `reference` query parameter.

```
https://example.com/payments/success?reference=TRANSACTION_OR_ORDER_REFERENCE

```

Use the `reference` to check the final payment status:

```
$reference = $_GET['reference'];
```

For card payments, the reference is the card order reference:

```
$status = $ctechpay->cards()->status($reference);
```

For Airtel Money payments, the reference is the Airtel transaction ID:

```
$details = $ctechpay->airtel()->details($reference);
```

Airtel Money
------------

[](#airtel-money)

### Initiate Payment

[](#initiate-payment)

```
$payment = $ctechpay->airtel()->pay([
    'amount' => 100,
    'phone' => '0999123456',
    'category_flag' => 'LOAN_APPLICATION',
    'customer_reference' => 'INV-1001',
    'customer_message' => 'Invoice payment',
]);

$transactionId = $payment['data']['transaction']['id'];
```

### Check Airtel Status

[](#check-airtel-status)

Use the transaction ID returned when initiating payment.

```
$status = $ctechpay->airtel()->status($transactionId);
```

### Get Airtel Transaction Details

[](#get-airtel-transaction-details)

```
$details = $ctechpay->airtel()->details($transactionId);
```

### Find CtechPay Transaction By Airtel Money ID

[](#find-ctechpay-transaction-by-airtel-money-id)

```
$reference = $ctechpay->airtel()->reference('AIRTEL_MONEY_ID');
```

Card Hosted Bank Page
---------------------

[](#card-hosted-bank-page)

This creates the Standard Bank hosted card checkout page.

```
$order = $ctechpay->cards()->createPaymentPage([
    'amount' => 100,
    'category_flag' => 'LOAN_APPLICATION',
    'merchantAttributes' => true,
    'redirectUrl' => 'https://example.com/payments/success',
    'cancelUrl' => 'https://example.com/payments/cancelled',
    'customer_reference' => 'INV-1001',
    'customer_message' => 'Invoice payment',
]);

header('Location: ' . $order['payment_page_URL']);
exit;
```

### Check Card Order Status

[](#check-card-order-status)

```
$status = $ctechpay->cards()->status($order['order_reference']);
```

Laravel Example
---------------

[](#laravel-example)

```
use CtechPay\CtechPay;

$ctechpay = CtechPay::client(config('services.ctechpay.token'));

$payment = $ctechpay->hostedPayments()->create([
    'amount' => 100,
    'category_flag' => 'LOAN_APPLICATION',
    'customer_reference' => 'ORDER-1001',
    'redirectUrl' => route('payments.success'),
    'cancelUrl' => route('payments.cancelled'),
]);

return redirect($payment['data']['hosted_payment_url']);
```

Payment Categories
------------------

[](#payment-categories)

If the merchant has configured payment categories in CtechPay, pass the category flag when creating the payment. This lets CtechPay allocate the transaction to the right category for balances, reports, and category-based settlements.

```
$payment = $ctechpay->hostedPayments()->create([
    'amount' => 10500,
    'category_flag' => 'LOAN_APPLICATION',
    'customer_reference' => 'APP-1001',
    'customer_message' => 'Loan application fee',
    'redirectUrl' => 'https://example.com/payments/success',
    'cancelUrl' => 'https://example.com/payments/cancelled',
]);
```

The PHP SDK also accepts `categoryFlag` and sends it to CtechPay as `category_flag`.

Supported payment category flows:

MethodCategory field`$ctechpay->hostedPayments()->create([...])``category_flag` or `categoryFlag``$ctechpay->airtel()->pay([...])``category_flag` or `categoryFlag``$ctechpay->cards()->createPaymentPage([...])``category_flag` or `categoryFlag`The flag must match an active payment category on the merchant account. Omit it when the payment should remain uncategorized.

In `config/services.php`:

```
'ctechpay' => [
    'token' => env('CTECHPAY_TOKEN'),
],
```

Error Handling
--------------

[](#error-handling)

The SDK throws `CtechPay\Exceptions\CtechPayException` for failed requests.

```
use CtechPay\Exceptions\CtechPayException;

try {
    $payment = $ctechpay->hostedPayments()->create([
        'amount' => 100,
    ]);
} catch (CtechPayException $e) {
    echo $e->getMessage();
    print_r($e->response);
}
```

Security Notes
--------------

[](#security-notes)

This SDK intentionally does not expose direct card PAN/CVV helpers. Use the CtechPay Hosted Payment Page for card collection unless your integration is formally approved for card-data handling.

Do not disable SSL verification in production.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity42

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

46d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/77573995?v=4)[Laughwell Bota](/maintainers/Laughwellreformed)[@Laughwellreformed](https://github.com/Laughwellreformed)

---

Top Contributors

[![Laughwellreformed](https://avatars.githubusercontent.com/u/77573995?v=4)](https://github.com/Laughwellreformed "Laughwellreformed (3 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ctechpay-ctechpay-php/health.svg)

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

PHPackages © 2026

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