kulmipay/kulmipay-php

PHP SDK for the KulmiPay API

Maintainers

Package info

github.com/kulmidigital/kulmipay-php-sdk

pkg:composer/kulmipay/kulmipay-php

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-05-28 13:06 UTC

This package is auto-updated.

Last update: 2026-05-28 13:26:47 UTC


README

PHP SDK for the KulmiPay API. Use it to create checkout sessions, collect M-Pesa and PesaLink payments, send money, manage wallets, and create or retrieve refunds.

Install

composer require kulmipay/kulmipay-php

Configure

use KulmiPay\KulmiPayPHP\Collection;

$credentials = [
    'token' => 'ISSecretKey_live_xxxxxxxxxxxxxxxx',
    'publishable_key' => 'ISPubKey_live_xxxxxxxxxxxxxxxx',
];

$collection = new Collection();
$collection->init($credentials);

For sandbox:

$credentials = [
    'token' => 'ISSecretKey_test_xxxxxxxxxxxxxxxx',
    'publishable_key' => 'ISPubKey_test_xxxxxxxxxxxxxxxx',
    'sandbox' => true,
];

For self-hosted deployments:

$credentials = [
    'token' => 'YOUR_SECRET_KEY',
    'publishable_key' => 'YOUR_PUBLIC_KEY',
    'base_url' => 'https://payments.example.com/api/v1',
];

Checkout

use KulmiPay\KulmiPayPHP\Checkout;
use KulmiPay\KulmiPayPHP\Customer;

$customer = new Customer();
$customer->first_name = 'Jane';
$customer->last_name = 'Doe';
$customer->email = 'jane@example.com';
$customer->phone_number = '254712345678';

$checkout = new Checkout();
$checkout->init($credentials);

$response = $checkout->create(
    1500,
    'KES',
    $customer,
    null,
    'https://merchant.example/thank-you',
    'ORDER-1001',
    null,
    null,
    'BUSINESS-PAYS',
    'BUSINESS-PAYS',
    null,
    true
);

echo $response->url;

M-Pesa STK Push

use KulmiPay\KulmiPayPHP\Collection;

$collection = new Collection();
$collection->init($credentials);

$response = $collection->mpesa_stk_push(
    '1500.00',
    '254712345678',
    'ORDER-1001'
);

echo $response->invoice->invoice_id;

PesaLink Collection

$response = $collection->pesalink(
    '5000.00',
    'KES',
    'ORDER-BANK-1001',
    [
        'email' => 'customer@example.com',
        'first_name' => 'Jane',
        'last_name' => 'Doe',
    ]
);

Payment Status

$response = $collection->status('GQ7KZ2XPNM');

Send Money

use KulmiPay\KulmiPayPHP\Transfer;

$transfer = new Transfer();
$transfer->init($credentials);

$transactions = [
    [
        'name' => 'Jane Doe',
        'account' => '254712345678',
        'amount' => '1000',
        'narrative' => 'Refund',
        'idempotency_key' => 'refund-1001',
    ],
];

$response = $transfer->mpesa('KES', $transactions, 'YES');
$status = $transfer->status($response->tracking_id);

Supported helpers:

Method Provider
$transfer->mpesa(...) MPESA-B2C
$transfer->mpesa_b2b(...) MPESA-B2B
$transfer->bank(...) PESALINK
$transfer->p2p(...) P2P

Wallets

use KulmiPay\KulmiPayPHP\Wallet;

$wallet = new Wallet();
$wallet->init($credentials);

$wallets = $wallet->retrieve();

$created = $wallet->create('KES', 'Payroll Wallet', true);

$transactions = $wallet->transactions($created->wallet_id);

Refunds

Refunds use the chargebacks API internally.

use KulmiPay\KulmiPayPHP\Refunds;

$refunds = new Refunds();
$refunds->init($credentials);

$refund = $refunds->create(
    'GQ7KZ2XPNM',
    '1500.00',
    'Duplicate payment'
);

$allRefunds = $refunds->retrieve();
$oneRefund = $refunds->details($refund->chargeback_id);