PHPackages                             lotesm/c-pay - 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. lotesm/c-pay

ActiveLibrary[Payment Processing](/categories/payments)

lotesm/c-pay
============

C-Pay card payment gateway SDK — works with any PHP project and integrates natively with Laravel/WooCommerce-style flows.

00PHPCI failing

Since Mar 17Pushed 3mo agoCompare

[ Source](https://github.com/lotesm/c-pay)[ Packagist](https://packagist.org/packages/lotesm/c-pay)[ RSS](/packages/lotesm-c-pay/feed)WikiDiscussions main Synced 3w ago

READMEChangelogDependenciesVersions (1)Used By (0)

C-Pay PHP SDK
=============

[](#c-pay-php-sdk)

[![Tests](https://github.com/lotesm/c-pay/actions/workflows/tests.yml/badge.svg)](https://github.com/lotesm/c-pay/actions)[![PHP](https://camo.githubusercontent.com/83dd395020c37276225039739320f6c8e7e99963ab21ee3d09282cb48dad2a60/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e312532422d626c7565)](https://php.net)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

A framework-agnostic PHP SDK for the **C-Pay card payment gateway** (Visa / MasterCard).
Includes first-class Laravel integration via a service provider, facade, controller, and Blade templates.

---

Requirements
------------

[](#requirements)

DependencyVersionPHP8.1+Guzzle^7.0Laravel *(optional)*10 or 11---

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

[](#installation)

```
composer require lotesm/c-pay
```

Laravel's auto-discovery registers the service provider and facade automatically.

### Publish config

[](#publish-config)

```
php artisan vendor:publish --tag=c-pay-config
```

### Publish views

[](#publish-views)

```
php artisan vendor:publish --tag=c-pay-views
```

### Publish assets

[](#publish-assets)

```
php artisan vendor:publish --tag=c-pay-assets
```

---

Configuration
-------------

[](#configuration)

Add to your `.env`:

```
CPAY_BASE_URL=https://cpay-uat-env.chaperone.co.ls:5100
CPAY_CLIENT_CODE=YOUR_CLIENT_CODE
CPAY_API_KEY=your-api-key
CPAY_CLIENT_SECRET=your-client-secret
CPAY_MERCHANT_CODE=your-merchant-code
CPAY_CURRENCY=LSL
CPAY_TEST_MODE=true
CPAY_SSL_VERIFY=true
```

---

Usage
-----

[](#usage)

### Laravel — Facade

[](#laravel--facade)

```
use CPay\Laravel\Facades\CPay;

// Initiate a card payment
$response = CPay::initiatePayment([
    'order_id'    => $order->id,
    'amount'      => number_format($order->total, 2, '.', ''),
    'msisdn'      => $order->billing_phone,
    'currency'    => 'LSL',
    'callbackUrl' => route('cpay.callback'),
]);

// Store the iframe HTML in session then redirect
session(['cpay_card_iframe_content' => $response->rawData]);

return redirect()->route('cpay.payment', ['order' => $order->id]);
```

### Laravel — Dependency Injection

[](#laravel--dependency-injection)

```
use CPay\PaymentManager;

class CheckoutController extends Controller
{
    public function __construct(private PaymentManager $cpay) {}

    public function pay(Order $order)
    {
        $response = $this->cpay->initiatePayment([
            'order_id' => $order->id,
            'amount'   => $order->formattedTotal(),
            'msisdn'   => $order->phone,
        ]);

        session(['cpay_card_iframe_content' => $response->rawData]);

        return redirect()->route('cpay.payment', ['order' => $order->id]);
    }
}
```

### Plain PHP (no framework)

[](#plain-php-no-framework)

```
use CPay\CPayClient;
use CPay\CPayConfig;
use CPay\PaymentManager;

$config  = CPayConfig::fromArray([
    'base_url'      => 'https://cpay-uat-env.chaperone.co.ls:5100',
    'client_code'   => 'MY_SHOP',
    'api_key'       => 'my-api-key',
    'client_secret' => 'my-secret',
]);

$manager  = new PaymentManager(new CPayClient($config));
$response = $manager->initiatePayment([
    'order_id' => 42,
    'amount'   => '199.00',
    'msisdn'   => '26657000000',
]);

if ($response->success && $response->statusCode === 202) {
    $iframeSrc = $manager->extractIframeSrc($response->rawData);
    // Render your own payment page with $iframeSrc
}
```

---

Routes (Laravel)
----------------

[](#routes-laravel)

The package registers the following routes automatically under the `/cpay` prefix:

MethodURINameDescriptionGET`/cpay/payment``cpay.payment`Renders the iframe payment pageGET`/cpay/confirmation``cpay.confirmation`Renders the payment confirmation pageGET`/cpay/callback``cpay.callback`Gateway callback (order status update)POST`/cpay/status``cpay.status`AJAX: poll order statusPOST`/cpay/cancel``cpay.cancel`AJAX: cancel a pending payment> **Important:** The callback and status routes contain `// TODO` comments.
> You **must** implement order lookup logic there to match your application's order model.

---

Customising Views
-----------------

[](#customising-views)

After publishing views (`--tag=c-pay-views`), templates land in `resources/views/vendor/c-pay/`:

TemplatePurpose`card-payment-process.blade.php`Full-screen iframe payment page`payment-confirmation.blade.php`Post-payment success page`card-payment-iframe.blade.php`OTP verification pagePass extra data to the confirmation template from your controller override:

```
return view('c-pay::payment-confirmation', [
    'orderId'         => $order->id,
    'transactionDate' => $order->paid_at->format('F j, Y g:i A'),
    'transactionId'   => $order->ext_transaction_id,
    'orderItems'      => $order->items->map(fn($i) => [
                           'quantity' => $i->qty,
                           'name'     => $i->product_name,
                           'price'    => 'LSL ' . number_format($i->total, 2),
                         ])->all(),
    'orderTotal'      => 'LSL ' . number_format($order->total, 2),
    'homeUrl'         => url('/'),
    'orderViewUrl'    => route('orders.show', $order),
    'shopUrl'         => route('shop.index'),
]);
```

---

Custom HTTP Client
------------------

[](#custom-http-client)

Swap out Guzzle with any HTTP client by implementing `HttpClientInterface`:

```
use CPay\Contracts\HttpClientInterface;

class MyHttpClient implements HttpClientInterface
{
    public function post(string $url, array $payload, array $headers = []): array { ... }
    public function get(string $url, array $query = [], array $headers = []): array { ... }
}

$client  = new CPayClient($config, new MyHttpClient());
$manager = new PaymentManager($client);
```

---

Testing
-------

[](#testing)

```
composer install
vendor/bin/phpunit
```

---

Migrating from the WordPress Plugin
-----------------------------------

[](#migrating-from-the-wordpress-plugin)

WordPressThis Package`Cpay_Card_API``CPay\CPayClient``WC_Cpay_Card_Gateway::process_payment()``PaymentManager::initiatePayment()``wp_remote_request()``GuzzleHttpClient` (swappable)`add_action('template_redirect', ...)``CPayController` (Laravel routes)`wp_ajax_*` handlers`CPayController` POST routesWooCommerce sessionLaravel `Session`PHP templatesBlade templates`CPAY_CARD_PLUGIN_URL` constant`asset('vendor/c-pay/assets/...')`---

License
-------

[](#license)

MIT © Kamoho Molapo — [jkmolapo.com](https://jkmolapo.com) by Moeketsi Titisi — [chaperone.co.ls](https://chaperone.co.ls)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance54

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/1e2b89c5b7f662af0f8c3281dfe4043edd6f291d96eae5854db7bfcacf21dd49?d=identicon)[lotesm](/maintainers/lotesm)

---

Top Contributors

[![lotesm](https://avatars.githubusercontent.com/u/34619025?v=4)](https://github.com/lotesm "lotesm (2 commits)")

### Embed Badge

![Health badge](/badges/lotesm-c-pay/health.svg)

```
[![Health](https://phpackages.com/badges/lotesm-c-pay/health.svg)](https://phpackages.com/packages/lotesm-c-pay)
```

###  Alternatives

[omnipay/coinbase

Coinbase driver for the Omnipay payment processing library

18570.2k1](/packages/omnipay-coinbase)

PHPackages © 2026

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